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

feat: add tools support for ollama #797

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

b4s36t4
Copy link
Contributor

@b4s36t4 b4s36t4 commented Dec 9, 2024

Title:
add tools support for ollama

Related Issues: (optional)

SDK Usage
import { Portkey } from "portkey-ai";

const portkey = new Portkey({
  baseURL: "http://localhost:8787/v1",
  provider: "ollama",
  customHost: "http://localhost:11434",
});

const tools = [
  {
    type: "function",
    function: {
      name: "get_current_weather",
      description: "Get the current weather for a location",
      parameters: {
        type: "object",
        properties: {
          location: {
            type: "string",
            description:
              "The location to get the weather for, e.g. San Francisco, CA",
          },
          format: {
            type: "string",
            description:
              "The format to return the weather in, e.g. 'celsius' or 'fahrenheit'",
            enum: ["celsius", "fahrenheit"],
          },
        },
        required: ["location", "format"],
      },
    },
  },
];

const completion = await portkey.chat.completions.create({
      model: "llama3.2:1b",
      messages: [
        {
          role: "system",
          content: "You are a helpful assistant",
        },
        {
          role: "user",
          content: "What is weather in canada?",
        },
      ],
      tools: tools,
});
console.log(JSON.stringify(completion));

@VisargD VisargD merged commit 589455d into Portkey-AI:main Dec 9, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants