-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,48 @@ | ||
// using FluentAssertions; | ||
// using LangChain.Base; | ||
// using LangChain.Callback; | ||
// using LangChain.Chains.LLM; | ||
// using LangChain.LLMS.OpenAi; | ||
// using LangChain.Prompts; | ||
// using LangChain.Schema; | ||
// | ||
// namespace LangChain.IntegrationTests; | ||
// | ||
// public class OpenAiTests | ||
// { | ||
// [Fact] | ||
// public async Task TestOpenAi_WithValidInput_ShouldReturnResponse() | ||
// { | ||
// var model = new OpenAi(); | ||
// | ||
// var result = await model.Call("What is a good name for a company that sells colourful socks?"); | ||
// | ||
// result.Should().NotBeEmpty(); | ||
// } | ||
// | ||
// [Fact] | ||
// public async Task TestOpenAi_WithChain_ShouldReturnResponse() | ||
// { | ||
// var llm = new OpenAi(); | ||
// | ||
// var template = "What is a good name for a company that makes {product}?"; | ||
// var prompt = new PromptTemplate(new PromptTemplateInput(template, new List<string>(1){"product"})); | ||
// | ||
// var chain = new LlmChain(new LlmChainInput(llm, prompt)); | ||
// | ||
// var result = await chain.Call(new ChainValues(new Dictionary<string, object>(1) | ||
// { | ||
// { "product", "colourful socks" } | ||
// })); | ||
// | ||
// // The result is an object with a `text` property. | ||
// result.Value["text"].ToString().Should().NotBeEmpty(); | ||
// } | ||
// } | ||
using LangChain.Chains.LLM; | ||
using LangChain.Prompts; | ||
using LangChain.Providers.OpenAI.Predefined; | ||
using LangChain.Schema; | ||
|
||
namespace LangChain.IntegrationTests; | ||
|
||
[TestFixture] | ||
[Explicit] | ||
public class OpenAiTests | ||
{ | ||
[Test] | ||
public async Task TestOpenAi_WithValidInput_ShouldReturnResponse() | ||
{ | ||
var model = new Gpt35TurboModel( | ||
Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? | ||
throw new InconclusiveException("OPENAI_API_KEY is not set")); | ||
|
||
string result = await model.GenerateAsync("What is a good name for a company that sells colourful socks?"); | ||
|
||
result.Should().NotBeEmpty(); | ||
|
||
Console.WriteLine(result); | ||
} | ||
|
||
[Test] | ||
public async Task TestOpenAi_WithChain_ShouldReturnResponse() | ||
{ | ||
var llm = new Gpt35TurboModel( | ||
Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? | ||
throw new InconclusiveException("OPENAI_API_KEY is not set")); | ||
|
||
var template = "What is a good name for a company that makes {product}?"; | ||
var prompt = new PromptTemplate(new PromptTemplateInput(template, new List<string>(1){"product"})); | ||
|
||
var chain = new LlmChain(new LlmChainInput(llm, prompt)); | ||
|
||
var result = await chain.CallAsync(new ChainValues(new Dictionary<string, object>(1) | ||
{ | ||
{ "product", "colourful socks" } | ||
})); | ||
|
||
// The result is an object with a `text` property. | ||
result.Value["text"].ToString().Should().NotBeEmpty(); | ||
|
||
Console.WriteLine(result.Value["text"]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.