Upload 3 files
Browse files
aglab.py
CHANGED
|
@@ -4,16 +4,42 @@ class AgLab:
|
|
| 4 |
def __init__(self, system_prompt: str = ""):
|
| 5 |
self.system_prompt = system_prompt
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def AskAgLabLLM(self, prompt: str) -> str:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
if __name__ == "__main__":
|
| 18 |
aglab = AgLab("You are a helpful assistant called ag lab llm.")
|
| 19 |
-
print(aglab.AskAgLabLLM("What is the capital of France, also what is your name?"))
|
|
|
|
| 4 |
def __init__(self, system_prompt: str = ""):
|
| 5 |
self.system_prompt = system_prompt
|
| 6 |
|
| 7 |
+
def __raw_ask(self, prompt: str) -> str:
|
| 8 |
+
'''
|
| 9 |
+
Internal method: Ask a question to the AgLab LLM and get a response as text.
|
| 10 |
+
'''
|
| 11 |
+
model = AIModel()
|
| 12 |
+
response = model.AskAI(prompt)
|
| 13 |
+
return response
|
| 14 |
+
|
| 15 |
def AskAgLabLLM(self, prompt: str) -> str:
|
| 16 |
+
'''
|
| 17 |
+
Ask a question to the AgLab LLM and get a response as text.
|
| 18 |
+
'''
|
| 19 |
+
full_prompt = self.system_prompt + " " + prompt
|
| 20 |
+
response = self.__raw_ask(full_prompt)
|
| 21 |
+
return response
|
| 22 |
+
|
| 23 |
+
def AskAgLabLLMWithContext(self, prompt: str, context: str) -> str:
|
| 24 |
+
'''
|
| 25 |
+
Ask a question to the AgLab LLM with context and get a response as text.
|
| 26 |
+
'''
|
| 27 |
+
full_prompt = (
|
| 28 |
+
self.system_prompt +
|
| 29 |
+
" Context of the chat so far: " + context +
|
| 30 |
+
" User said: " + prompt
|
| 31 |
+
)
|
| 32 |
+
response = self.__raw_ask(full_prompt)
|
| 33 |
+
return response
|
| 34 |
+
|
| 35 |
+
def SummarizeText(self, text: str) -> str:
|
| 36 |
+
'''
|
| 37 |
+
Summarize a text using the AgLab LLM and get a response as text.
|
| 38 |
+
'''
|
| 39 |
+
full_prompt = " Summarize the following text: " + text + " send only the summary of the previous text, do not reply, send only the summary."
|
| 40 |
+
response = self.__raw_ask(full_prompt)
|
| 41 |
+
return response
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
| 44 |
aglab = AgLab("You are a helpful assistant called ag lab llm.")
|
| 45 |
+
print(aglab.AskAgLabLLM("What is the capital of France, also what is your name?"))
|
main.py
CHANGED
|
@@ -4,5 +4,5 @@ Main Script to use the AG AI Lab
|
|
| 4 |
|
| 5 |
import aglab
|
| 6 |
|
| 7 |
-
lab = aglab.AgLab()
|
| 8 |
print(lab.AskAgLabLLM("What is the capital of France, also what is your name?"))
|
|
|
|
| 4 |
|
| 5 |
import aglab
|
| 6 |
|
| 7 |
+
lab = aglab.AgLab("Your name is ag lab llm. You are a helpful assistant.")
|
| 8 |
print(lab.AskAgLabLLM("What is the capital of France, also what is your name?"))
|