Spaces:
Running
Running
Inclusion of Claude and Cohere to the panel
Browse files
ring.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
from getpass import getpass
|
| 3 |
from langchain_ai21 import AI21LLM
|
|
|
|
|
|
|
| 4 |
from langchain_openai import OpenAI
|
| 5 |
|
| 6 |
from langchain.prompts import PromptTemplate
|
|
@@ -13,10 +15,12 @@ LLM_GPT4o = "GPT4o"
|
|
| 13 |
LLM_LLAMA2 = "LLAMA2"
|
| 14 |
LLM_GEMINI = "Gemini"
|
| 15 |
LLM_AI21 = "AI21"
|
|
|
|
|
|
|
| 16 |
|
| 17 |
OPENAI_LLMS = [LLM_GPT35, LLM_GPT4, LLM_GPT4o]
|
| 18 |
|
| 19 |
-
PREF_ORDER_LLMS = (LLM_GEMINI, LLM_LLAMA2, LLM_GPT35, LLM_GPT4, LLM_GPT4o, LLM_AI21)
|
| 20 |
|
| 21 |
|
| 22 |
def requires_openai_key(llm_ver):
|
|
@@ -55,6 +59,18 @@ def get_ai21_api_key():
|
|
| 55 |
|
| 56 |
return ai21_api_key
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
def get_llm(llm_ver, temperature):
|
| 59 |
|
| 60 |
if llm_ver == LLM_GPT35:
|
|
@@ -109,6 +125,22 @@ def get_llm(llm_ver, temperature):
|
|
| 109 |
model="j2-ultra"
|
| 110 |
)
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
return llm
|
| 113 |
|
| 114 |
|
|
|
|
| 1 |
import os
|
| 2 |
from getpass import getpass
|
| 3 |
from langchain_ai21 import AI21LLM
|
| 4 |
+
from langchain_anthropic import AnthropicLLM
|
| 5 |
+
from langchain_cohere import Cohere
|
| 6 |
from langchain_openai import OpenAI
|
| 7 |
|
| 8 |
from langchain.prompts import PromptTemplate
|
|
|
|
| 15 |
LLM_LLAMA2 = "LLAMA2"
|
| 16 |
LLM_GEMINI = "Gemini"
|
| 17 |
LLM_AI21 = "AI21"
|
| 18 |
+
LLM_Claude2 = "Claude2.1"
|
| 19 |
+
LLM_Cohere = "Cohere"
|
| 20 |
|
| 21 |
OPENAI_LLMS = [LLM_GPT35, LLM_GPT4, LLM_GPT4o]
|
| 22 |
|
| 23 |
+
PREF_ORDER_LLMS = (LLM_GEMINI, LLM_LLAMA2, LLM_GPT35, LLM_GPT4, LLM_GPT4o, LLM_AI21, LLM_Claude2, LLM_Cohere)
|
| 24 |
|
| 25 |
|
| 26 |
def requires_openai_key(llm_ver):
|
|
|
|
| 59 |
|
| 60 |
return ai21_api_key
|
| 61 |
|
| 62 |
+
def get_claude_key():
|
| 63 |
+
|
| 64 |
+
claude_api_key = os.environ.get["CLAUDE_API_KEY"]
|
| 65 |
+
|
| 66 |
+
return claude_api_key
|
| 67 |
+
|
| 68 |
+
def get_cohere_key():
|
| 69 |
+
|
| 70 |
+
cohere_api_key = os.environ.get["COHERE_API_KEY"]
|
| 71 |
+
|
| 72 |
+
return cohere_api_key
|
| 73 |
+
|
| 74 |
def get_llm(llm_ver, temperature):
|
| 75 |
|
| 76 |
if llm_ver == LLM_GPT35:
|
|
|
|
| 125 |
model="j2-ultra"
|
| 126 |
)
|
| 127 |
|
| 128 |
+
elif llm_ver == LLM_Claude2:
|
| 129 |
+
|
| 130 |
+
from langchain_anthropic import AnthropicLLM
|
| 131 |
+
|
| 132 |
+
llm = Anthropic(
|
| 133 |
+
model="claude-2.1"
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
elif llm_ver == LLM_Cohere:
|
| 137 |
+
|
| 138 |
+
from langchain_cohere import Cohere
|
| 139 |
+
|
| 140 |
+
llm = Cohere(
|
| 141 |
+
model = "Cohere Command R" #double check
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
return llm
|
| 145 |
|
| 146 |
|