AGofficial commited on
Commit
533e375
·
verified ·
1 Parent(s): 026e75e

Upload 3 files

Browse files
Files changed (3) hide show
  1. aglab.py +19 -0
  2. main.py +8 -0
  3. model.py +22 -0
aglab.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from model import AIModel
2
+
3
+ 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
+ Ask a question to the AgLab LLM and get a response as text.
10
+ '''
11
+ model = AIModel()
12
+ full_prompt = self.system_prompt + " " + prompt
13
+ response = model.AskAI(full_prompt)
14
+ return response
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?"))
main.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ Main Script to use the AG AI Lab
3
+ '''
4
+
5
+ import aglab
6
+
7
+ lab = aglab.AgLab()
8
+ print(lab.AskAgLabLLM("What is the capital of France, also what is your name?"))
model.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ '''
2
+ You can change the AI model by modifying the function 'AskAI()' below.
3
+ '''
4
+
5
+ import requests
6
+ import urllib.parse
7
+
8
+ class AIModel:
9
+ def AskAI(self, prompt: str) -> str:
10
+ base_url = "https://text.pollinations.ai/"
11
+ encoded_prompt = urllib.parse.quote(prompt)
12
+ full_url = base_url + encoded_prompt
13
+
14
+ response = requests.get(full_url)
15
+ if response.status_code == 200:
16
+ return response.text
17
+ else:
18
+ return f"<error> | Error: {response.status_code} - {response.text}"
19
+
20
+ if __name__ == "__main__":
21
+ model = AIModel()
22
+ print(model.AskAI("Tell me the capital of France, please."))