Upload aggpt10.py
Browse files- aggpt10.py +34 -0
aggpt10.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from llama_cpp import Llama
|
| 2 |
+
|
| 3 |
+
class AgGPT:
|
| 4 |
+
def __init__(self, model_path):
|
| 5 |
+
self.model_path = model_path
|
| 6 |
+
self.model = Llama(model_path=model_path, n_ctx=2048, n_gpu_layers=35)
|
| 7 |
+
|
| 8 |
+
def run(self):
|
| 9 |
+
while True:
|
| 10 |
+
prompt = input("\nEnter your prompt: ")
|
| 11 |
+
|
| 12 |
+
messages = [
|
| 13 |
+
{"role": "system", "content": f"You are AgGPT-10, an AGI system. The user said: '{prompt}'."},
|
| 14 |
+
{"role": "user", "content": prompt}
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
output = self.model.create_chat_completion(messages, max_tokens=1050, temperature=0.7)
|
| 18 |
+
print(output["choices"][0]["message"]["content"])
|
| 19 |
+
|
| 20 |
+
def ask(self, question):
|
| 21 |
+
''' Ask AgGPT-10 a question and return the answer. '''
|
| 22 |
+
messages = [
|
| 23 |
+
{"role": "system", "content": f"You are AgGPT-10, an AGI system. The user said: '{question}'."},
|
| 24 |
+
{"role": "user", "content": question}
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
output = self.model.create_chat_completion(messages, max_tokens=1050, temperature=0.7)
|
| 28 |
+
|
| 29 |
+
return output["choices"][0]["message"]["content"]
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
model_path = "aggpt10.gguf"
|
| 33 |
+
aggpt = AgGPT(model_path)
|
| 34 |
+
aggpt.run()
|