Compare commits

...

2 Commits

  1. 16
      matrix_pygmalion_bot/bot/ai/prompts.py
  2. 24
      matrix_pygmalion_bot/bot/wrappers/langchain_koboldcpp.py

16
matrix_pygmalion_bot/bot/ai/prompts.py

@ -211,6 +211,22 @@ Provide an outline of {ai_name}'s day in keywords.
# briefly, as a list, use bullet points, outline the main points what character needs to remember about the day, in note form, review ... point by point
prompt_document_answering = PromptTemplate.from_template(
"""Write a high-quality answer for the given question using only the provided search
results (some of which might be irrelevant).
Document [1](Title: Asian Americans in science and technology) Prize in physics for
discovery of the subatomic particle J/ψ. Subrahmanyan Chandrasekhar shared...
Document [2](Title: List of Nobel laureates in Physics) The first Nobel Prize in
Physics was awarded in 1901 to Wilhelm Conrad Röntgen, of Germany, who received...
Document [3](Title: Scientist) and pursued through a unique method, was essentially
in place. Ramón y Cajal won the Nobel Prize in 1906 for his remarkable...
Question: who got the first nobel prize in physics
Answer:"""
)
prompt_agent = PromptTemplate.from_template(
"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request and explain what actions were used.

24
matrix_pygmalion_bot/bot/wrappers/langchain_koboldcpp.py

@ -60,7 +60,7 @@ class KoboldCpp(LLM):
"top_k": self.top_k,
"top_p": self.top_p,
"rep_pen": self.repeat_penalty,
"rep_pen_range": 256,
"rep_pen_range": 1024,
"stop_sequence": self.stop,
}
@ -110,7 +110,7 @@ class KoboldCpp(LLM):
"top_k": self.top_k,
"top_p": self.top_p,
"rep_pen": self.repeat_penalty,
"rep_pen_range": 256,
"rep_pen_range": 1024,
"stop_sequence": self.stop,
}
@ -123,13 +123,28 @@ class KoboldCpp(LLM):
logger.info(f"sending request to koboldcpp.")
TRIES = 30
TRIES = 60
request_timeout=20*60
for i in range(TRIES):
try:
loop = asyncio.get_running_loop()
#r = requests.post(self.endpoint_url, json=input_data, headers=headers, timeout=600)
r = await loop.run_in_executor(None, functools.partial(requests.post, self.endpoint_url, json=input_data, headers=headers, timeout=600))
r = await loop.run_in_executor(None, functools.partial(requests.post, self.endpoint_url, json=input_data, headers=headers, timeout=request_timeout))
#r.raise_for_status()
r_json = r.json()
except requests.exceptions.HTTPError as errh:
print ("Http Error:",errh)
await asyncio.sleep(5)
continue
except requests.exceptions.ConnectionError as errc:
print ("Error Connecting:",errc)
await asyncio.sleep(5)
continue
except requests.exceptions.Timeout as errt:
raise ValueError(f"http timeout error.")
#print ("Timeout Error:",errt)
#await asyncio.sleep(5)
#continue
except requests.exceptions.RequestException as e:
raise ValueError(f"http connection error.")
logger.info(r_json)
@ -142,6 +157,7 @@ class KoboldCpp(LLM):
elif r.status_code == 503:
logger.info(f"api is busy. waiting...")
await asyncio.sleep(5)
continue
else:
raise ValueError(f"http error. unknown response code")
for s in input_data["stop_sequence"]:

Loading…
Cancel
Save