adadd conformance tests for azure open ai
Signed-off-by: fabistb <fabian0401@online.de>
This commit is contained in:
parent
84e3fe6667
commit
77e1ced4a6
|
|
@ -5,7 +5,7 @@ This directory contains conformance tests for all conversation components, inclu
|
||||||
## Available Components
|
## Available Components
|
||||||
|
|
||||||
- **echo** - Simple echo component for testing (no configuration needed)
|
- **echo** - Simple echo component for testing (no configuration needed)
|
||||||
- **openai** - OpenAI GPT models
|
- **openai** - OpenAI GPT models (also supports Azure OpenAI)
|
||||||
- **anthropic** - Anthropic Claude models
|
- **anthropic** - Anthropic Claude models
|
||||||
- **googleai** - Google Gemini models
|
- **googleai** - Google Gemini models
|
||||||
- **mistral** - Mistral AI models
|
- **mistral** - Mistral AI models
|
||||||
|
|
@ -52,6 +52,14 @@ export OPENAI_API_KEY="your_openai_api_key"
|
||||||
```
|
```
|
||||||
Get your API key from: https://platform.openai.com/api-keys
|
Get your API key from: https://platform.openai.com/api-keys
|
||||||
|
|
||||||
|
### Azure OpenAI
|
||||||
|
```bash
|
||||||
|
export AZURE_OPENAI_API_KEY="your_openai_api_key"
|
||||||
|
export AZURE_OPENAI_ENDPOINT="your_azureopenai_endpoint_here"
|
||||||
|
export AZURE_OPENAI_API_VERSION="your_azreopenai_api_version_here"
|
||||||
|
```
|
||||||
|
Get your configuration values from: https://ai.azure.com/
|
||||||
|
|
||||||
### Anthropic
|
### Anthropic
|
||||||
```bash
|
```bash
|
||||||
export ANTHROPIC_API_KEY="your_anthropic_api_key"
|
export ANTHROPIC_API_KEY="your_anthropic_api_key"
|
||||||
|
|
@ -142,4 +150,5 @@ This approach provides better reliability and compatibility while maintaining ac
|
||||||
- Cost-effective models are used by default to minimize API costs
|
- Cost-effective models are used by default to minimize API costs
|
||||||
- HuggingFace uses the OpenAI compatibility layer as a workaround due to langchaingo API issues
|
- HuggingFace uses the OpenAI compatibility layer as a workaround due to langchaingo API issues
|
||||||
- Ollama requires a local server and must be explicitly enabled
|
- Ollama requires a local server and must be explicitly enabled
|
||||||
|
- OpenAI component is tested for OpenAI and Azure
|
||||||
- All tests include proper initialization and basic conversation functionality testing
|
- All tests include proper initialization and basic conversation functionality testing
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
# OpenAI API Key - Get from https://platform.openai.com/api-keys
|
# OpenAI API Key - Get from https://platform.openai.com/api-keys
|
||||||
OPENAI_API_KEY=your_openai_api_key_here
|
OPENAI_API_KEY=your_openai_api_key_here
|
||||||
|
|
||||||
|
# Azure OpenAI - Get from https://ai.azure.com/
|
||||||
|
AZURE_OPENAI_API_KEY=your_azureopenai_api_key_here
|
||||||
|
AZURE_OPENAI_ENDPOINT=your_azureopenai_endpoint_here
|
||||||
|
AZURE_OPENAI_API_VERSION=your_azreopenai_api_version_here
|
||||||
|
|
||||||
# Anthropic API Key - Get from https://console.anthropic.com/
|
# Anthropic API Key - Get from https://console.anthropic.com/
|
||||||
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
apiVersion: dapr.io/v1alpha1
|
||||||
|
kind: Component
|
||||||
|
metadata:
|
||||||
|
name: openai
|
||||||
|
spec:
|
||||||
|
type: conversation.openai
|
||||||
|
version: v1
|
||||||
|
metadata:
|
||||||
|
- name: key
|
||||||
|
value: "${{AZURE_OPENAI_API_KEY}}"
|
||||||
|
- name: model
|
||||||
|
value: "gpt-4o-mini"
|
||||||
|
- name: endpoint
|
||||||
|
value: "${{AZURE_OPENAI_ENDPOINT}}"
|
||||||
|
- name: apiType
|
||||||
|
value: "azure"
|
||||||
|
- name: apiVersion
|
||||||
|
value: "${{AZURE_OPENAI_API_VERSION}}"
|
||||||
|
|
@ -9,4 +9,4 @@ spec:
|
||||||
- name: key
|
- name: key
|
||||||
value: "${{OPENAI_API_KEY}}"
|
value: "${{OPENAI_API_KEY}}"
|
||||||
- name: model
|
- name: model
|
||||||
value: "gpt-4o-mini"
|
value: "gpt-4.1"
|
||||||
|
|
@ -21,6 +21,9 @@ echo " ./test_conformance.sh"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Option 2: Set environment variables directly:"
|
echo "Option 2: Set environment variables directly:"
|
||||||
echo " export OPENAI_API_KEY=\"your_openai_api_key\""
|
echo " export OPENAI_API_KEY=\"your_openai_api_key\""
|
||||||
|
echo " export AZURE_OPENAI_API_KEY=\"your_azureopenai_api_key\""
|
||||||
|
echo " export AZURE_OPENAI_ENDPOINT=\"your_azureopenai_endpoint\""
|
||||||
|
echo " export AZURE_OPENAI_API_VERSION=\"your_azureopenai_api_version\""
|
||||||
echo " export ANTHROPIC_API_KEY=\"your_anthropic_api_key\""
|
echo " export ANTHROPIC_API_KEY=\"your_anthropic_api_key\""
|
||||||
echo " export GOOGLE_AI_API_KEY=\"your_google_ai_api_key\""
|
echo " export GOOGLE_AI_API_KEY=\"your_google_ai_api_key\""
|
||||||
echo " export MISTRAL_API_KEY=\"your_mistral_api_key\""
|
echo " export MISTRAL_API_KEY=\"your_mistral_api_key\""
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ componentType: conversation
|
||||||
components:
|
components:
|
||||||
- component: echo
|
- component: echo
|
||||||
operations: []
|
operations: []
|
||||||
- component: openai
|
- component: openai.openai
|
||||||
|
operations: []
|
||||||
|
- component: openai.azure
|
||||||
operations: []
|
operations: []
|
||||||
- component: anthropic
|
- component: anthropic
|
||||||
operations: []
|
operations: []
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,16 @@ func TestConversationConformance(t *testing.T) {
|
||||||
// shouldSkipComponent checks if a component test should be skipped due to missing environment variables
|
// shouldSkipComponent checks if a component test should be skipped due to missing environment variables
|
||||||
func shouldSkipComponent(t *testing.T, componentName string) bool {
|
func shouldSkipComponent(t *testing.T, componentName string) bool {
|
||||||
switch componentName {
|
switch componentName {
|
||||||
case "openai":
|
case "openai.openai":
|
||||||
if os.Getenv("OPENAI_API_KEY") == "" {
|
if os.Getenv("OPENAI_API_KEY") == "" {
|
||||||
t.Skipf("Skipping OpenAI conformance test: OPENAI_API_KEY environment variable not set")
|
t.Skipf("Skipping OpenAI conformance test: OPENAI_API_KEY environment variable not set")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
case "openai.azure":
|
||||||
|
if os.Getenv("AZURE_OPENAI_API_KEY") == "" || os.Getenv("AZURE_OPENAI_ENDPOINT") == "" || os.Getenv("AZURE_OPENAI_API_TYPE") == "" || os.Getenv("AZURE_OPENAI_API_VERSION") == "" {
|
||||||
|
t.Skipf("Skipping Azure OpenAI conformance test: AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_TYPE, and AZURE_OPENAI_API_VERSION environment variables must be set")
|
||||||
|
return true
|
||||||
|
}
|
||||||
case "anthropic":
|
case "anthropic":
|
||||||
if os.Getenv("ANTHROPIC_API_KEY") == "" {
|
if os.Getenv("ANTHROPIC_API_KEY") == "" {
|
||||||
t.Skipf("Skipping Anthropic conformance test: ANTHROPIC_API_KEY environment variable not set")
|
t.Skipf("Skipping Anthropic conformance test: ANTHROPIC_API_KEY environment variable not set")
|
||||||
|
|
@ -117,7 +122,7 @@ func loadConversationComponent(name string) conversation.Conversation {
|
||||||
switch name {
|
switch name {
|
||||||
case "echo":
|
case "echo":
|
||||||
return echo.NewEcho(testLogger)
|
return echo.NewEcho(testLogger)
|
||||||
case "openai":
|
case "openai.openai", "openai.azure":
|
||||||
return openai.NewOpenAI(testLogger)
|
return openai.NewOpenAI(testLogger)
|
||||||
case "anthropic":
|
case "anthropic":
|
||||||
return anthropic.NewAnthropic(testLogger)
|
return anthropic.NewAnthropic(testLogger)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue