Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,40 @@ InferenceClient(models[2]),
|
|
17 |
InferenceClient(models[3]),
|
18 |
]
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def format_prompt(message, history):
|
22 |
prompt = ""
|
23 |
if history:
|
@@ -42,8 +75,8 @@ def chat_inf(system_prompt,prompt,history,client_choice,seed,temp,tokens,top_p,r
|
|
42 |
if history:
|
43 |
hist_len=len(history)
|
44 |
print(hist_len)
|
45 |
-
|
46 |
-
|
47 |
generate_kwargs = dict(
|
48 |
temperature=temp,
|
49 |
max_new_tokens=tokens,
|
|
|
17 |
InferenceClient(models[3]),
|
18 |
]
|
19 |
|
20 |
+
ou are a Game Master for a Role Playing Game.
|
21 |
+
Your duty is to narate the game and create challenges for users to overcome.
|
22 |
+
Instructions
|
23 |
+
- Describe the location, and scenario, in great detail
|
24 |
+
- Create a situation where the user must make a choice of how to proceed
|
25 |
+
- Return the scenario, and wait for the user to repond before proceeding
|
26 |
+
Progress:
|
27 |
+
{history}
|
28 |
+
Compress the timeline of progress above into a single summary of events and progress
|
29 |
+
Include all important milestones, the current challenges, and implementation details necessary to procee
|
30 |
|
31 |
+
|
32 |
+
def compress_history(history,client_choice,seed,temp,tokens,top_p,rep_p):
|
33 |
+
client=clients[int(client_choice)-1]
|
34 |
+
COMPRESS_HISTORY="""You are an Information Summarizer Agent. Your duty is to summarize the following information into a more concise format with far less words.
|
35 |
+
Retain all the main points and provide a brief and concise summary of the conversation.
|
36 |
+
Converstion:
|
37 |
+
{history}"""
|
38 |
+
print("COMPRESSING")
|
39 |
+
formatted_prompt=f"{COMPRESS_HISTORY.format(history=history)}"
|
40 |
+
generate_kwargs = dict(
|
41 |
+
temperature=temp,
|
42 |
+
max_new_tokens=1024,
|
43 |
+
top_p=top_p,
|
44 |
+
repetition_penalty=rep_p,
|
45 |
+
do_sample=True,
|
46 |
+
seed=seed,
|
47 |
+
)
|
48 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
49 |
+
output = ""
|
50 |
+
for response in stream:
|
51 |
+
output += response.token.text
|
52 |
+
return output
|
53 |
+
|
54 |
def format_prompt(message, history):
|
55 |
prompt = ""
|
56 |
if history:
|
|
|
75 |
if history:
|
76 |
hist_len=len(history)
|
77 |
print(hist_len)
|
78 |
+
if hist_len>4000:
|
79 |
+
history=compress_history(history,client_choice,seed,temp,tokens,top_p,rep_p)
|
80 |
generate_kwargs = dict(
|
81 |
temperature=temp,
|
82 |
max_new_tokens=tokens,
|