Giter Club home page Giter Club logo

Comments (3)

rizerphe avatar rizerphe commented on July 19, 2024 1

Thanks a lot for your time! I've just published this fix, it should be working out of the box.

from openai-functions.

rizerphe avatar rizerphe commented on July 19, 2024

Sorry for making you wait. I do not have access to the Azure OpenAI service, still tried to implement a fix, though. Can you confirm whether updating the package and passing in the engine parameter (your deployment ID) into Conversation or nlp solves the issue?

from openai-functions.

zwx00 avatar zwx00 commented on July 19, 2024

Hey I was able to get this to work but with one catch.

openai.api_type = "azure"
openai.api_key = "..."
openai.api_base = "https://blabla.openai.azure.com"
openai.api_version = "2023-07-01-preview"
engine = "blabla"

conversation = openai_functions.Conversation(model="gpt-4", engine=engine)

There was an issue with Azure OpenAI implementation not returning the content field in messages. I had to make the below modification. Let me know if I'm using it wrong or should I open a PR for this.

# openai_types.py
class Message:
    # more stuff
    def __init__(
        self,
        message: MessageType | str,
        role: Literal["system", "user", "assistant"] = "user",
    ):
        if isinstance(message, str):
            if role == "assistant":  # We have to split this up because of mypy
                self.message: MessageType = {"role": role, "content": message}
            else:
                self.message = {
                    "role": role,
                    "content": message,
                }
        else:
            # NEW CODE 
            if "content" not in message:
                message["content"] = None
            # END NEW CODE

            self.message = message

Sorry for sharing code in this barbaric manner I'm super busy at the moment.

from openai-functions.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.