Bom dia.
Ao codificar atualmente a solução, estou encontrando dificuldades em consertar o problema abaixo.
Como sou novado no OpenAI, tentei ver documentação mas nao ficou claro. Usei de várias maneiras o Copilot integrado ao VSCode mas ele selecionava importar uma biblioteca do OpenAI nao acessivel.
Ambiente:
VSCODE
Ambiente virtual configurado
Python 3.13.0
CODIGO:
from openai import OpenAI
import os
from dotenv import load_dotenv
import tiktoken
....
lista_mensagens = [
{
"role": "system",
"content": prompt_sistema
},
{
"role": "user",
"content": prompt_usuario
}
]
resposta = client.chat.completions.create(
model=modelo,
messages=lista_mensagens
)
print(resposta.choices[0].message.content)
ERRO
Argument of type "list[dict[str, str]]" cannot be assigned to parameter "messages" of type "Iterable[ChatCompletionMessageParam]" in function "create"
"list[dict[str, str]]" is not assignable to "Iterable[ChatCompletionMessageParam]"
Type parameter "_T_co@Iterable" is covariant, but "dict[str, str]" is not a subtype of "ChatCompletionMessageParam"
Type "dict[str, str]" is not assignable to type "ChatCompletionMessageParam"
"dict[str, str]" is not assignable to "ChatCompletionDeveloperMessageParam"
"dict[str, str]" is not assignable to "ChatCompletionSystemMessageParam"
"dict[str, str]" is not assignable to "ChatCompletionUserMessageParam"
"dict[str, str]" is not assignable to "ChatCompletionAssistantMessageParam"
"dict[str, str]" is not assignable to "ChatCompletionToolMessageParam"
...