Spaces:
Running
Running
Changes for AI21
Browse files- requirements.txt +3 -2
- ring.py +9 -1
- test.py +7 -0
requirements.txt
CHANGED
|
@@ -9,5 +9,6 @@ neuromllite
|
|
| 9 |
matplotlib
|
| 10 |
pylems
|
| 11 |
pyneuroml
|
| 12 |
-
paper-qa
|
| 13 |
-
langchain-google-genai
|
|
|
|
|
|
| 9 |
matplotlib
|
| 10 |
pylems
|
| 11 |
pyneuroml
|
| 12 |
+
paper-qa
|
| 13 |
+
langchain-google-genai
|
| 14 |
+
langchain_ai21
|
ring.py
CHANGED
|
@@ -16,7 +16,7 @@ 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,
|
| 20 |
|
| 21 |
|
| 22 |
def requires_openai_key(llm_ver):
|
|
@@ -101,6 +101,14 @@ def get_llm(llm_ver, temperature):
|
|
| 101 |
model="gemini-pro", google_api_key=get_gemini_api_key()
|
| 102 |
)
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
return llm
|
| 105 |
|
| 106 |
|
|
|
|
| 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):
|
|
|
|
| 101 |
model="gemini-pro", google_api_key=get_gemini_api_key()
|
| 102 |
)
|
| 103 |
|
| 104 |
+
elif llm_ver == LLM_AI21:
|
| 105 |
+
|
| 106 |
+
from langchain_ai21 import AI21LLM
|
| 107 |
+
|
| 108 |
+
llm = AI21LLM(
|
| 109 |
+
model="j2-ultra"
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
return llm
|
| 113 |
|
| 114 |
|
test.py
CHANGED
|
@@ -3,6 +3,7 @@ from ring import LLM_GPT4
|
|
| 3 |
from ring import LLM_GPT4o
|
| 4 |
from ring import LLM_LLAMA2
|
| 5 |
from ring import LLM_GEMINI
|
|
|
|
| 6 |
from ring import PREF_ORDER_LLMS
|
| 7 |
|
| 8 |
from ring import generate_response
|
|
@@ -16,6 +17,12 @@ llm_ver = LLM_GPT4o
|
|
| 16 |
if "-g" in sys.argv:
|
| 17 |
llm_ver = LLM_GEMINI
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
print("--------------------------------------------------------")
|
| 21 |
print("Asking question:\n %s" % question)
|
|
|
|
| 3 |
from ring import LLM_GPT4o
|
| 4 |
from ring import LLM_LLAMA2
|
| 5 |
from ring import LLM_GEMINI
|
| 6 |
+
from ring import LLM_AI21
|
| 7 |
from ring import PREF_ORDER_LLMS
|
| 8 |
|
| 9 |
from ring import generate_response
|
|
|
|
| 17 |
if "-g" in sys.argv:
|
| 18 |
llm_ver = LLM_GEMINI
|
| 19 |
|
| 20 |
+
if "-l" in sys.argv:
|
| 21 |
+
llm_ver = LLM_LLAMA2
|
| 22 |
+
|
| 23 |
+
if "-a" in sys.argv:
|
| 24 |
+
llm_ver = LLM_AI21
|
| 25 |
+
|
| 26 |
|
| 27 |
print("--------------------------------------------------------")
|
| 28 |
print("Asking question:\n %s" % question)
|