Skip to content

Commit

Permalink
why are we here
Browse files Browse the repository at this point in the history
  • Loading branch information
mirakst committed Nov 9, 2023
1 parent 5fd1cb8 commit 8f5c6fd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 23 deletions.
8 changes: 4 additions & 4 deletions ChatRPG/API/HttpMessageHandlerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ public HttpMessageHandler CreateHandler(string name)
return new HttpClientHandler();
}

var mockHttpMessageHandler = new MockHttpMessageHandler();
mockHttpMessageHandler.When("*")
MockHttpMessageHandler messageHandler = new MockHttpMessageHandler();
messageHandler.When("*")
.Respond(GenerateMockResponse);

return mockHttpMessageHandler;
return messageHandler;
}

private static HttpResponseMessage GenerateMockResponse(HttpRequestMessage request)
{
Console.Write("Please enter mocked API response: ");
string input = Console.ReadLine();

Check warning on line 31 in ChatRPG/API/HttpMessageHandlerFactory.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
var responseContent = new StringContent($$"""
StringContent responseContent = new StringContent($$"""
{
"id": "chatcmpl-000",
"object": "chat.completion",
Expand Down
4 changes: 2 additions & 2 deletions ChatRPG/API/OpenAiLlmClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public OpenAiLlmClient(IConfiguration configuration, IHttpClientFactory httpClie

public async Task<string> GetChatCompletion(OpenAiGptMessage input)
{
var inputList = new List<OpenAiGptMessage> { input };
List<OpenAiGptMessage> inputList = new List<OpenAiGptMessage> { input };
return await GetChatCompletion(inputList);
}

Expand All @@ -35,7 +35,7 @@ public async Task<string> GetChatCompletion(List<OpenAiGptMessage> inputs)

public IAsyncEnumerable<string> GetStreamedChatCompletion(OpenAiGptMessage input)
{
var inputList = new List<OpenAiGptMessage> { input };
List<OpenAiGptMessage> inputList = new List<OpenAiGptMessage> { input };
return GetStreamedChatCompletion(inputList);
}

Expand Down
14 changes: 0 additions & 14 deletions ChatRPG/ChatRPG.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="ChatRPG\bin\Debug\net7.0\appsettings.Development.json" />
<_ContentIncludedByDefault Remove="ChatRPG\bin\Debug\net7.0\appsettings.json" />
<_ContentIncludedByDefault Remove="ChatRPG\bin\Debug\net7.0\ChatRPG.deps.json" />
<_ContentIncludedByDefault Remove="ChatRPG\bin\Debug\net7.0\ChatRPG.runtimeconfig.json" />
<_ContentIncludedByDefault Remove="ChatRPG\bin\Debug\net7.0\ChatRPG.staticwebassets.runtime.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\ChatRPG.csproj.nuget.dgspec.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\Debug\net7.0\staticwebassets.build.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\Debug\net7.0\staticwebassets.development.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\Debug\net7.0\staticwebassets.pack.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\project.assets.json" />
<_ContentIncludedByDefault Remove="ChatRPG\obj\project.packagespec.json" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions ChatRPG/Pages/Campaign.razor
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
}
_isWaitingForResponse = true;

var userInput = new OpenAiGptMessage("user", _userInput);
OpenAiGptMessage userInput = new OpenAiGptMessage("user", _userInput);
_conversation.Add(userInput);

if (!_shouldStream)
Expand All @@ -114,7 +114,7 @@

private void HandleResponse(string response)
{
var assistantOutput = new OpenAiGptMessage("assistant", response);
OpenAiGptMessage assistantOutput = new OpenAiGptMessage("assistant", response);
_conversation.Add(assistantOutput);
}

Expand Down
2 changes: 1 addition & 1 deletion ChatRPG/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

var httpMessageHandlerFactory = new HttpMessageHandlerFactory(configuration);
HttpMessageHandlerFactory httpMessageHandlerFactory = new HttpMessageHandlerFactory(configuration);
builder.Services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<User>>()
.AddSingleton(httpMessageHandlerFactory)
.AddSingleton<IHttpClientFactory, HttpClientFactory>()
Expand Down

0 comments on commit 8f5c6fd

Please sign in to comment.