Skip to content

Commit

Permalink
closes#367 Fix: Prevent BaseDomain override in HttpClient requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhantolga committed Oct 6, 2023
1 parent a212749 commit 1591894
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion OpenAI.Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//await ImageTestHelper.RunSimpleCreateImageTest(sdk);
//await ImageTestHelper.RunSimpleCreateImageEditTest(sdk);
//await ImageTestHelper.RunSimpleCreateImageVariationTest(sdk);
//await ModerationTestHelper.CreateModerationTest(sdk);
await ModerationTestHelper.CreateModerationTest(sdk);
//await CompletionTestHelper.RunSimpleCompletionTest(sdk);
//await CompletionTestHelper.RunSimpleCompletionTest2(sdk);
//await CompletionTestHelper.RunSimpleCompletionTest3(sdk);
Expand Down
8 changes: 4 additions & 4 deletions OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AzureOpenAiEndpointProvider(string apiVersion, string deploymentId)
_deploymentId = deploymentId;
}

private string Prefix => $"/{ApiPrefix}/{DeploymentsPrefix}/{WebUtility.UrlEncode(_deploymentId)}";
private string Prefix => $"{ApiPrefix}/{DeploymentsPrefix}/{WebUtility.UrlEncode(_deploymentId)}";
private string QueryString => $"?api-version={_apiVersion}";


Expand Down Expand Up @@ -58,12 +58,12 @@ public string FilesUpload()

public string FileRetrieve(string fileId)
{
return $"/{Prefix}/files/{fileId}{QueryString}";
return $"{Prefix}/files/{fileId}{QueryString}";
}

public string FileRetrieveContent(string fileId)
{
return $"/{Prefix}/files/{fileId}/content{QueryString}";
return $"{Prefix}/files/{fileId}/content{QueryString}";
}

public string FineTuneCreate()
Expand Down Expand Up @@ -103,7 +103,7 @@ public string FineTuningJobCreate()

public string FineTuningJobList(FineTuningJobListRequest? fineTuningJobListRequest)
{
var url = $"/{Prefix}/fine_tuning/jobs";
var url = $"{Prefix}/fine_tuning/jobs";
if (fineTuningJobListRequest != null)
{
var queryParams = new List<string>();
Expand Down
56 changes: 28 additions & 28 deletions OpenAI.SDK/EndpointProviders/OpenAiEndpointProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@ public OpenAiEndpointProvider(string apiVersion)

public string ModelRetrieve(string model)
{
return $"/{_apiVersion}/models/{model}";
return $"{_apiVersion}/models/{model}";
}

public string FileDelete(string fileId)
{
return $"/{_apiVersion}/files/{fileId}";
return $"{_apiVersion}/files/{fileId}";
}

public string CompletionCreate()
{
return $"/{_apiVersion}/completions";
return $"{_apiVersion}/completions";
}

public string ChatCompletionCreate()
{
return $"/{_apiVersion}/chat/completions";
return $"{_apiVersion}/chat/completions";
}

public string AudioCreateTranscription()
{
return $"/{_apiVersion}/audio/transcriptions";
return $"{_apiVersion}/audio/transcriptions";
}

public string AudioCreateTranslation()
{
return $"/{_apiVersion}/audio/translations";
return $"{_apiVersion}/audio/translations";
}

public string EditCreate()
{
return $"/{_apiVersion}/edits";
return $"{_apiVersion}/edits";
}

public string ModelsList()
{
return $"/{_apiVersion}/models";
return $"{_apiVersion}/models";
}

public string FilesList()
Expand All @@ -64,52 +64,52 @@ public string FilesUpload()

public string FileRetrieve(string fileId)
{
return $"/{_apiVersion}/files/{fileId}";
return $"{_apiVersion}/files/{fileId}";
}

public string FileRetrieveContent(string fileId)
{
return $"/{_apiVersion}/files/{fileId}/content";
return $"{_apiVersion}/files/{fileId}/content";
}

public string FineTuneCreate()
{
return $"/{_apiVersion}/fine-tunes";
return $"{_apiVersion}/fine-tunes";
}

public string FineTuneList()
{
return $"/{_apiVersion}/fine-tunes";
return $"{_apiVersion}/fine-tunes";
}

public string FineTuneRetrieve(string fineTuneId)
{
return $"/{_apiVersion}/fine-tunes/{fineTuneId}";
return $"{_apiVersion}/fine-tunes/{fineTuneId}";
}

public string FineTuneCancel(string fineTuneId)
{
return $"/{_apiVersion}/fine-tunes/{fineTuneId}/cancel";
return $"{_apiVersion}/fine-tunes/{fineTuneId}/cancel";
}

public string FineTuneListEvents(string fineTuneId)
{
return $"/{_apiVersion}/fine-tunes/{fineTuneId}/events";
return $"{_apiVersion}/fine-tunes/{fineTuneId}/events";
}

public string FineTuneDelete(string fineTuneId)
{
return $"/{_apiVersion}/models/{fineTuneId}";
return $"{_apiVersion}/models/{fineTuneId}";
}

public string FineTuningJobCreate()
{
return $"/{_apiVersion}/fine_tuning/jobs";
return $"{_apiVersion}/fine_tuning/jobs";
}

public string FineTuningJobList(FineTuningJobListRequest? fineTuningJobListRequest)
{
var url = $"/{_apiVersion}/fine_tuning/jobs";
var url = $"{_apiVersion}/fine_tuning/jobs";
if (fineTuningJobListRequest != null)
{
var queryParams = new List<string>();
Expand All @@ -126,51 +126,51 @@ public string FineTuningJobList(FineTuningJobListRequest? fineTuningJobListReque

public string FineTuningJobRetrieve(string fineTuningJobId)
{
return $"/{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}";
return $"{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}";
}

public string FineTuningJobCancel(string fineTuningJobId)
{
return $"/{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}/cancel";
return $"{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}/cancel";
}

public string FineTuningJobListEvents(string fineTuningJobId)
{
return $"/{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}/events";
return $"{_apiVersion}/fine_tuning/jobs/{fineTuningJobId}/events";
}

public string ModelsDelete(string modelId)
{
return $"/{_apiVersion}/models/{modelId}";
return $"{_apiVersion}/models/{modelId}";
}

public string EmbeddingCreate()
{
return $"/{_apiVersion}/embeddings";
return $"{_apiVersion}/embeddings";
}

public string ModerationCreate()
{
return $"/{_apiVersion}/moderations";
return $"{_apiVersion}/moderations";
}

public string ImageCreate()
{
return $"/{_apiVersion}/images/generations";
return $"{_apiVersion}/images/generations";
}

public string ImageEditCreate()
{
return $"/{_apiVersion}/images/edits";
return $"{_apiVersion}/images/edits";
}

public string ImageVariationCreate()
{
return $"/{_apiVersion}/images/variations";
return $"{_apiVersion}/images/variations";
}

private string Files()
{
return $"/{_apiVersion}/files";
return $"{_apiVersion}/files";
}
}

0 comments on commit 1591894

Please sign in to comment.