LLAMA-QA-AudioFiles / llm_ops.py
Samarth991's picture
application to run llama-7b on Audio files
2faf743
raw
history blame
797 Bytes
import os
def get_openai_chat_model(API_key):
try:
from langchain.llms import OpenAI
except ImportError as err:
raise "{}, unable to load openAI. Please install openai and add OPENAIAPI_KEY"
os.environ["OPENAI_API_KEY"] = API_key
llm = OpenAI()
return llm
def get_hugging_face_model(model_id,API_key,temperature=0.1,max_tokens=4096):
try:
from langchain import HuggingFaceHub
except ImportError as err:
raise "{}, unable to load openAI. Please install openai and add OPENAIAPI_KEY"
chat_llm = HuggingFaceHub(huggingfacehub_api_token=API_key,
repo_id=model_id,
model_kwargs={"temperature": temperature, "max_new_tokens": max_tokens})
return chat_llm