-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from jodendaal/develop
Removal of TextEdit and Deprecated Models
- Loading branch information
Showing
30 changed files
with
305 additions
and
580 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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using OpenAI.Net.Models; | ||
using OpenAI.Net.Models.Requests; | ||
|
||
namespace OpenAI.Net.Integration.Tests | ||
{ | ||
public class EmbeddingService: BaseTest | ||
{ | ||
[Test] | ||
public async Task Create() | ||
{ | ||
var request = new EmbeddingsRequest("this is a test", OpenAIDefaults.EmbeddingsModel); | ||
var response = await OpenAIService.Embeddings.Create(request); | ||
|
||
Assert.That(response.IsSuccess, Is.True); | ||
Assert.That(response.Result?.Data?.Count(), Is.GreaterThanOrEqualTo(1)); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,46 @@ | ||
using System.Net; | ||
|
||
namespace OpenAI.Net.Integration.Tests | ||
{ | ||
internal class ModelsService : BaseTest | ||
{ | ||
[TestCase(ModelTypes.TextDavinciEdit001,true, HttpStatusCode.OK,TestName = "GetById_When_Success")] | ||
[TestCase("invalid_model", false, HttpStatusCode.NotFound,TestName = "GetById_When_Invalid_Model_Fail")] | ||
public async Task GetById(string model,bool isSuccess, HttpStatusCode statusCode) | ||
{ | ||
|
||
|
||
var response = await OpenAIService.Models.Get(model); | ||
|
||
Assert.That(response.IsSuccess, Is.EqualTo(isSuccess), "Request failed"); | ||
Assert.That(response.StatusCode, Is.EqualTo(statusCode)); | ||
Assert.That(response.Result?.Id == ModelTypes.TextDavinciEdit001, Is.EqualTo(isSuccess), "Choices are not mapped correctly"); | ||
} | ||
|
||
[TestCase(true, HttpStatusCode.OK)] | ||
public async Task GetAll(bool isSuccess, HttpStatusCode statusCode) | ||
{ | ||
|
||
|
||
var response = await OpenAIService.Models.Get(); | ||
|
||
Assert.That(response.IsSuccess, Is.EqualTo(isSuccess), "Request failed"); | ||
Assert.That(response.StatusCode, Is.EqualTo(statusCode)); | ||
Assert.That(response.Result?.Data.Count() > 0, Is.EqualTo(isSuccess), "Choices are not mapped correctly"); | ||
} | ||
} | ||
} | ||
using Newtonsoft.Json; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Reflection; | ||
|
||
namespace OpenAI.Net.Integration.Tests | ||
{ | ||
internal class ModelsService : BaseTest | ||
{ | ||
[TestCase(ModelTypes.GPT35Turbo,true, HttpStatusCode.OK,TestName = "GetById_When_Success")] | ||
[TestCase("invalid_model", false, HttpStatusCode.NotFound,TestName = "GetById_When_Invalid_Model_Fail")] | ||
public async Task GetById(string model,bool isSuccess, HttpStatusCode statusCode) | ||
{ | ||
var response = await OpenAIService.Models.Get(model); | ||
|
||
Assert.That(response.IsSuccess, Is.EqualTo(isSuccess), "Request failed"); | ||
Assert.That(response.StatusCode, Is.EqualTo(statusCode)); | ||
Assert.That(response.Result?.Id == ModelTypes.GPT35Turbo, Is.EqualTo(isSuccess), "Choices are not mapped correctly"); | ||
} | ||
|
||
[TestCase(true, HttpStatusCode.OK)] | ||
public async Task GetAll(bool isSuccess, HttpStatusCode statusCode) | ||
{ | ||
var response = await OpenAIService.Models.Get(); | ||
|
||
Assert.That(response.IsSuccess, Is.EqualTo(isSuccess), "Request failed"); | ||
Assert.That(response.StatusCode, Is.EqualTo(statusCode)); | ||
Assert.That(response.Result?.Data.Count() > 0, Is.EqualTo(isSuccess), "Choices are not mapped correctly"); | ||
} | ||
|
||
[TestCase(true, HttpStatusCode.OK)] | ||
public async Task ValidateModelTypesModel(bool isSuccess, HttpStatusCode statusCode) | ||
{ | ||
var response = await OpenAIService.Models.Get(); | ||
var allModels = response?.Result?.Data.Select(i => i.Id).ToList()!; | ||
var definedModelTypes = typeof(ModelTypes).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Select(fieldInfo => fieldInfo.GetRawConstantValue()?.ToString()); | ||
|
||
var invalidModelTypes = definedModelTypes.Where(model => !allModels.Contains(model)).ToList(); | ||
var missingModelTypes = allModels.Where(id => !id.Contains("ft-personal") && !id.Contains("gpt-3.5-turbo-0301")).Where(model => !definedModelTypes.Contains(model)).ToList(); | ||
|
||
|
||
Assert.That(invalidModelTypes.Count, Is.EqualTo(0), $"Invalid models found {string.Join("\r\n", invalidModelTypes)}"); | ||
Assert.That(missingModelTypes.Count, Is.EqualTo(0), $"Missing models found {string.Join("\r\n", missingModelTypes)}"); | ||
} | ||
} | ||
} |
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.