agent icon indicating copy to clipboard operation
agent copied to clipboard

Feature request: ollama-js adapter to work locally

Open otrebu opened this issue 1 year ago • 9 comments

Create a ollama-js adapter to have the option to use ollama instead of OpenAI.

If you are not working on this I might give it a go.

otrebu avatar Feb 21 '24 20:02 otrebu

@otrebu I would gladly welcome you to give this a try - it should be as simple as copying from the OpenAI adapter.

davidkpiano avatar Feb 21 '24 21:02 davidkpiano

I started on it, but I have a question: do you have any suggestions in how to deal with tools? Ollama doesn't currently seem to support the same functionality/API for that.

otrebu avatar Feb 26 '24 19:02 otrebu

I started on it, but I have a question: do you have any suggestions in how to deal with tools? Ollama doesn't currently seem to support the same functionality/API for that.

Let's just stub this for now.

davidkpiano avatar Feb 29 '24 17:02 davidkpiano

I have done my best so far, a bit stuck on some Typescript types.

What is it best to do if I need a little hand? Still open a pull request?

This is the commit on the fork: https://github.com/otrebu/agent/commit/334b077e1e495cebcceaff453f238f4010184cdc

I haven't tested the code yet.

otrebu avatar Mar 17 '24 12:03 otrebu

Yes please @otrebu, open a pull request and I will gladly work on this with you.

davidkpiano avatar Mar 17 '24 12:03 davidkpiano

Amazing thanks @davidkpiano .

Hopefully I created it correctly: https://github.com/statelyai/agent/pull/24 ( first one ever for me 😄 )

otrebu avatar Mar 17 '24 12:03 otrebu

@davidkpiano did you have a chance to have a look? Otherwise I will try again after I rebase.

otrebu avatar May 19 '24 12:05 otrebu

@davidkpiano did you have a chance to have a look? Otherwise I will try again after I rebase.

I have recently added the Vercel AI SDK, which abstracts multiple models. I will see if/how ollama can be used with that, but it's a much more scalable solution than trying to build our own adapters 😅

davidkpiano avatar May 19 '24 12:05 davidkpiano

Oh ok, thank you! Sounds good.

otrebu avatar May 19 '24 12:05 otrebu

yep we don't need this.

this exists :

import { createAgent } from '@stately/agent';
import { createOllama } from 'ollama-ai-provider';

const ollama = createOllama({ baseURL: process.env.MY_AMAZEBALLS_OLLAMA_BASEURL });

// found with ollama --list
const myCustomOllamaModelName = process.env.MY_AMAZEBALLS_OLLAMA_MODELNAME || 'mixtral';

const model = ollama(myCustomOllamaModelName');

const agent = createAgent({
  name: 'my-foo-bar-agent',
  model,
  events: {
   	//... my amazing events
  },
});

airtonix avatar Jun 28 '24 06:06 airtonix

Thank you, I will close.

otrebu avatar Jun 30 '24 10:06 otrebu