-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
bugSomething isn't workingSomething isn't workingpythonPull requests for the Python Semantic KernelPull requests for the Python Semantic Kernel
Description
Describe the bug
I ran the following example with SemanticKernel 0.5.0.dev0.
https://github.com/microsoft/semantic-kernel/blob/main/python/notebooks/11-streaming-completions.ipynb
The code is as follows.
service = AzureChatCompletion(
deployment_name=AZURE_OPENAI_DEPLOYMENT_NAME,
endpoint=AZURE_OPENAI_ENDPOINT,
api_key=AZURE_OPENAI_API_KEY,
api_version="2023-12-01-preview",
)
role = "system"
content = "You are an AI assistant that helps people find information."
message = {"role": role, "content": content}
az_oai_chat_prompt_execution_settings = AzureChatPromptExecutionSettings(
max_tokens=150,
temperature=0.7,
top_p=1,
frequency_penalty=0.5,
presence_penalty=0.5,
ai_model_id="gpt-4",
)
stream = service.complete_chat_stream(
messages=[message], settings=az_oai_chat_prompt_execution_settings
)
async for text in stream:
print(
text[0].inner_content.choices[0].delta.content, end=""
)When I run it, I get the following error:
AttributeError: 'Choice' object has no attribute 'logprobs'Expected behavior
The response from Azure OpenAI Chat Completion is output.
Platform
- OS: Mac M2
- IDE: VS Code
- Language: Python
- Source: pip package version 23.3.2 semantic kernel 0.5.0.dev0
- API: Azure OpenAI API GPT-4
Additional context
I think the reason is that Azure OpenAI's Chat Completion does not include logprobs.
For example, the following curl will not return logprobs
curl "https://*******.openai.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2023-12-01-preview" \
-H "Content-Type: application/json" \
-H "api-key: **************" \
-d "{
\"messages\": [{\"role\":\"system\",\"content\":\"You are an AI assistant that helps people find information.\"},{\"role\":\"user\",\"content\":\"hello\"},{\"role\":\"assistant\",\"content\":\"Hello! How can I help you today? If you have any questions or need assistance, feel free to ask.\"}],
\"max_tokens\": 800,
\"temperature\": 0.7,
\"frequency_penalty\": 0,
\"presence_penalty\": 0,
\"top_p\": 0.95,
\"stop\": null
}"
Also, checking the OpenAPI Schema, it was not defined.
Swagger 2023-12-01-preview
Swagger 2023-05-15
How about modifying it as follows:
https://github.com/yuichiromukaiyama/semantic-kernel/commit/9cedc95b4ce9bf7aff6ae16892df757076ca1bbb
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpythonPull requests for the Python Semantic KernelPull requests for the Python Semantic Kernel
Type
Projects
Status
Sprint: Done