Skip to content

Commit 065e51c

Browse files
authored
Fix Telemetry and Assistant tests (#165)
1 parent d5b5c60 commit 065e51c

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ It is generated from our [OpenAPI specification](https://github.com/openai/opena
2626
- [Advanced scenarios](#advanced-scenarios)
2727
- [Using protocol methods](#using-protocol-methods)
2828
- [Automatically retrying errors](#automatically-retrying-errors)
29-
- [Observability](#observability)
29+
- [Observability](#observability)
3030

3131
## Getting started
3232

@@ -751,6 +751,6 @@ By default, the client classes will automatically retry the following errors up
751751
- 503 Service Unavailable
752752
- 504 Gateway Timeout
753753

754-
## Observability
754+
### Observability
755755

756756
OpenAI .NET library supports experimental distributed tracing and metrics with OpenTelemetry. Check out [Observability with OpenTelemetry](./docs/observability.md) for more details.

api/OpenAI.netstandard2.0.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,12 @@ public enum GeneratedSpeechVoice {
10881088
Nova = 4,
10891089
Shimmer = 5
10901090
}
1091+
public static class OpenAIAudioModelFactory {
1092+
public static AudioTranscription AudioTranscription(string language = null, TimeSpan? duration = null, string text = null, IEnumerable<TranscribedWord> words = null, IEnumerable<TranscribedSegment> segments = null);
1093+
public static AudioTranslation AudioTranslation(string language = null, TimeSpan? duration = null, string text = null, IEnumerable<TranscribedSegment> segments = null);
1094+
public static TranscribedSegment TranscribedSegment(int id = 0, long seekOffset = 0, TimeSpan start = default, TimeSpan end = default, string text = null, IEnumerable<long> tokenIds = null, float temperature = 0, double averageLogProbability = 0, float compressionRatio = 0, double noSpeechProbability = 0);
1095+
public static TranscribedWord TranscribedWord(string word = null, TimeSpan start = default, TimeSpan end = default);
1096+
}
10911097
public class SpeechGenerationOptions : IJsonModel<SpeechGenerationOptions>, IPersistableModel<SpeechGenerationOptions> {
10921098
public GeneratedSpeechFormat? ResponseFormat { get; set; }
10931099
public float? Speed { get; set; }
@@ -1593,6 +1599,11 @@ public class EmbeddingTokenUsage : IJsonModel<EmbeddingTokenUsage>, IPersistable
15931599
string IPersistableModel<EmbeddingTokenUsage>.GetFormatFromOptions(ModelReaderWriterOptions options);
15941600
BinaryData IPersistableModel<EmbeddingTokenUsage>.Write(ModelReaderWriterOptions options);
15951601
}
1602+
public static class OpenAIEmbeddingsModelFactory {
1603+
public static Embedding Embedding(int index = 0, IEnumerable<float> vector = null);
1604+
public static EmbeddingCollection EmbeddingCollection(IEnumerable<Embedding> items = null, string model = null, EmbeddingTokenUsage usage = null);
1605+
public static EmbeddingTokenUsage EmbeddingTokenUsage(int inputTokens = 0, int totalTokens = 0);
1606+
}
15961607
}
15971608
namespace OpenAI.Files {
15981609
public class FileClient {
@@ -1868,6 +1879,10 @@ public class ImageVariationOptions : IJsonModel<ImageVariationOptions>, IPersist
18681879
string IPersistableModel<ImageVariationOptions>.GetFormatFromOptions(ModelReaderWriterOptions options);
18691880
BinaryData IPersistableModel<ImageVariationOptions>.Write(ModelReaderWriterOptions options);
18701881
}
1882+
public static class OpenAIImagesModelFactory {
1883+
public static GeneratedImage GeneratedImage(BinaryData imageBytes = null, Uri imageUri = null, string revisedPrompt = null);
1884+
public static GeneratedImageCollection GeneratedImageCollection(DateTimeOffset createdAt = default, IEnumerable<GeneratedImage> items = null);
1885+
}
18711886
}
18721887
namespace OpenAI.Models {
18731888
public class ModelClient {

tests/Assistants/AssistantTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public partial class AssistantTests
2424
protected void Cleanup()
2525
{
2626
// Skip cleanup if there is no API key (e.g., if we are not running live tests).
27-
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OPEN_API_KEY")))
27+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OPENAI_API_KEY")))
2828
{
2929
return;
3030
}

tests/Telemetry/TestActivityListener.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void Dispose()
3535
_listener.Dispose();
3636
}
3737

38-
public static void ValidateChatActivity(Activity activity, ChatCompletion response, string requestModel = "gpt-3.5-turbo", string host = "api.openai.com", int port = 443)
38+
public static void ValidateChatActivity(Activity activity, ChatCompletion response, string requestModel = "gpt-4o-mini", string host = "api.openai.com", int port = 443)
3939
{
4040
Assert.NotNull(activity);
4141
Assert.AreEqual($"chat {requestModel}", activity.DisplayName);
@@ -64,7 +64,7 @@ public static void ValidateChatActivity(Activity activity, ChatCompletion respon
6464
}
6565
}
6666

67-
public static void ValidateChatActivity(Activity activity, Exception ex, string requestModel = "gpt-3.5-turbo", string host = "api.openai.com", int port = 443)
67+
public static void ValidateChatActivity(Activity activity, Exception ex, string requestModel = "gpt-4o-mini", string host = "api.openai.com", int port = 443)
6868
{
6969
ValidateChatActivity(activity, (ChatCompletion)null, requestModel, host, port);
7070
Assert.AreEqual(ex.GetType().FullName, activity.GetTagItem("error.type"));

tests/Telemetry/TestMeterListener.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void Dispose()
6060
_listener.Dispose();
6161
}
6262

63-
public static void ValidateChatMetricTags(TestMeasurement measurement, ChatCompletion response, string requestModel = "gpt-3.5-turbo", string host = "api.openai.com", int port = 443)
63+
public static void ValidateChatMetricTags(TestMeasurement measurement, ChatCompletion response, string requestModel = "gpt-4o-mini", string host = "api.openai.com", int port = 443)
6464
{
6565
Assert.AreEqual("openai", measurement.tags["gen_ai.system"]);
6666
Assert.AreEqual("chat", measurement.tags["gen_ai.operation.name"]);
@@ -75,7 +75,7 @@ public static void ValidateChatMetricTags(TestMeasurement measurement, ChatCompl
7575
}
7676
}
7777

78-
public static void ValidateChatMetricTags(TestMeasurement measurement, Exception ex, string requestModel = "gpt-3.5-turbo", string host = "api.openai.com", int port = 443)
78+
public static void ValidateChatMetricTags(TestMeasurement measurement, Exception ex, string requestModel = "gpt-4o-mini", string host = "api.openai.com", int port = 443)
7979
{
8080
ValidateChatMetricTags(measurement, (ChatCompletion)null, requestModel, host, port);
8181
Assert.True(measurement.tags.ContainsKey("error.type"));

0 commit comments

Comments
 (0)