promptslab / PromptifyJs

Solve NLP Problems with Large Language Models in JavaScript
Apache License 2.0
21 stars 3 forks source link

[Feature Request] Integrate Openai and huggingFace model #9

Open rk-teche opened 1 year ago

rk-teche commented 1 year ago

Need to Implement openai and huggingFace model inside the models folder which we have.

openai model file - https://github.com/promptslab/PromptifyJs/blob/f9176cb7b703995470f4095233bf6660f8839093/models/openai.js#L2

For hugging-Face -> We need to create a new file and then implement it

Node Package reference -

Promptify reference - hub-model - https://github.com/promptslab/Promptify/blob/main/promptify/models/nlp/hub_model.py openai-model - https://github.com/promptslab/Promptify/blob/main/promptify/models/nlp/openai_model.py

rk-teche commented 1 year ago

openAI model integrated along with updated NER example.

Need to integrate - huggingFace model (Just to acknowledge the progress)

ishaan-jaff commented 1 year ago

Hi @rk-teche I’m the maintainer of LiteLLM (abstraction to call 100+ LLMs)- we allow you to create a proxy server to call 100+ LLMs, and I think it can solve your problem (I'd love your feedback if it does not)

Try it here: https://docs.litellm.ai/docs/proxy_server https://github.com/BerriAI/litellm

Using LiteLLM Proxy Server

import openai
openai.api_base = "http://0.0.0.0:8000/" # proxy url
print(openai.ChatCompletion.create(model="test", messages=[{"role":"user", "content":"Hey!"}]))

Creating a proxy server

Ollama models

$ litellm --model ollama/llama2 --api_base http://localhost:11434

Hugging Face Models

$ export HUGGINGFACE_API_KEY=my-api-key #[OPTIONAL]
$ litellm --model claude-instant-1

Anthropic

$ export ANTHROPIC_API_KEY=my-api-key
$ litellm --model claude-instant-1

Palm

$ export PALM_API_KEY=my-palm-key
$ litellm --model palm/chat-bison