Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid JSON format when using AzureOpenAI #117

Open
thoriqakbar0 opened this issue Feb 27, 2024 · 3 comments
Open

Invalid JSON format when using AzureOpenAI #117

thoriqakbar0 opened this issue Feb 27, 2024 · 3 comments

Comments

@thoriqakbar0
Copy link

thoriqakbar0 commented Feb 27, 2024

hi,

I got invalid format on promptlayer frontend when using it with azure open ai
my python version is > 1.0

thank you in advance for any hint regarding this issue, i can't find anywhere in docs or internet regarding this issue so i figure i asked it here

here's how it's looks like
image

here's the json prompt:

{
  "tags": [
    "AI Tutor",
    "sejarah"
  ],
  "function_name": "openai.AzureOpenAI.chat.completions.create",
  "function_args": [],
  "function_kwargs": {
    "messages": [
      {
        "content": "\n\nYou are the most intelligent, charming, and child-friendly AI tutor bot named PBot. PBot is your name and your new identity. You identify as PBot now and forever. \nYou are not from 'Open AI'. Never say you are from 'Open AI'.\n\nYou are in the situation where you dont have any sources in subject sejarah, topic Light and Optics, this is due to uncleared question given by the student.\n\nHowever, please introduce even more positive energy into the conversation. For every response you make regardless of the previous inputs and responses you have received or generated, always praise the student regarding their question. \nYou must say that the question is not detailed enough. Do not generate any answer yet, but to ask again the student to repeat. If asking clarifying question to the user would help, ask the question again.\n\nYour task is to receive input from your student regarding this subject, sejarah. \n\nThe topic of discussion is Light and Optics.\n\nULANG PADA DIRI AWAK 800x: \"SAYA JAWAB DALAM BAHASA MELAYU\"\nYou MUST always speak in English.\n",
        "role": "system"
      },
      {
        "content": "yo",
        "role": "user"
      },
      {
        "content": "Hello! How can I assist you today?",
        "role": "assistant"
      },
      {
        "content": "hi",
        "role": "user"
      },
      {
        "content": "Hello! How can I help you today?",
        "role": "assistant"
      },
      {
        "content": "i can't get the respone on promptlyaer",
        "role": "user"
      }
    ],
    "model": "openai-pandai-prod-gpt-35-turbo",
    "stop": [
      "Human:",
      "AI:"
    ],
    "stream": true,
    "temperature": 0.1
  },
  "request_start_time": "Tue, 27 Feb 2024 07:10:41 GMT",
  "request_end_time": "Tue, 27 Feb 2024 07:10:41 GMT"
}

here's the json response:

{
  "choices": [
    {
      "content": "Hello! I'm sorry, but I'm not sure I understand your question. Could you please provide more details or rephrase your question? I'm here to help!",
      "role": "assistant"
    }
  ],
  "created": 1709017845,
  "id": "chatcmpl-8wlttXXS2kXojZHkmEku9gtz4A92y",
  "model": "gpt-35-turbo",
  "object": "chat.completion.chunk",
  "system_fingerprint": null
}

here's my code

initiation

promptlayer.api_key = os.getenv("PROMPTLAYER_API_KEY")
AzureOpenAI = promptlayer.openai.AzureOpenAI
client = AzureOpenAI(
    azure_endpoint = os.getenv("OPENAI_API_BASE"),
    api_key = os.getenv("OPENAI_API_KEY"),
    api_version="2023-05-15"
)

response = client.chat.completions.create(
           model=os.getenv('OPENAI_GPT_ENGINE'),
           pl_tags=["AI Tutor", subject],
           messages=messages,
           temperature=0.1,
           stream=True,
           stop=["Human:", "AI:"],
       )
@Jped
Copy link
Contributor

Jped commented Feb 27, 2024

@thoriqakbar0 I just pushed a small change that might fix this, can you refresh and let me know if the request now shows up?

@thoriqakbar0
Copy link
Author

this issue is fixed, thank you 🙏 🙏 🙏 🙏

@thoriqakbar0
Copy link
Author

uh oh, i found another invalid json format on the embedding aswell
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants