Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
Last active February 5, 2025 07:27
Show Gist options
  • Save jamesmurdza/c25fa8e5ab250dbc4068f3c6078a1eff to your computer and use it in GitHub Desktop.
Save jamesmurdza/c25fa8e5ab250dbc4068f3c6078a1eff to your computer and use it in GitHub Desktop.
class MistralBaseProvider(OpenAIBaseProvider):
def create_function_def(self, name, details, properties, required):
# Wrap all descriptions to avoid Mistral validation error.
details["description"] = {"type": "string", "description": details.get("description")}
return super().create_function_def(name, details, properties, required)
def call(self, messages, functions=None):
# Make the last message a prefix if its role is assistant.
if messages and messages[-1].get("role") == "assistant":
messages[-1]["prefix"] = True
return super().call(messages, functions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment