FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
llama-cpp-python/examples/low_level_api/ReasonAct.py at main · DIT4FUN/llama-cpp-python · GitHub
DIT4FUN
/
llama-cpp-python
Public
forked from
abetlen/llama-cpp-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
llama-cpp-python
/
examples
/
low_level_api
/
ReasonAct.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (44 loc) · 1.42 KB
Breadcrumbs
llama-cpp-python
/
examples
/
low_level_api
/
ReasonAct.py
Copy path
File metadata and controls
53 lines (44 loc) · 1.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/python
import
sys
,
os
,
datetime
from
common
import
GptParams
from
low_level_api_chat_cpp
import
LLaMAInteract
def
env_or_def
(
env
,
default
):
if
env
in
os
.
environ
:
return
os
.
environ
[
env
]
return
default
MODEL
=
env_or_def
(
"MODEL"
,
"./models/llama-13B/ggml-model.bin"
)
prompt
=
f"""You run in a loop of Thought, Action, Observation.
At the end of the loop either Answer or restate your Thought and Action.
Use Thought to describe your thoughts about the question you have been asked.
Use Action to run one of these actions available to you:
- calculate[python math expression]
Observation will be the result of running those actions
Question: What is 4 * 7 / 3?
Thought: Do I need to use an action? Yes, I use calculate to do math
Action: calculate[4 * 7 / 3]
Observation: 9.3333333333
Thought: Do I need to use an action? No, have the result
Answer: The calculate tool says it is 9.3333333333
Question: What is capital of france?
Thought: Do I need to use an action? No, I know the answer
Answer: Paris is the capital of France
Question:"""
+
" "
.
join
(
sys
.
argv
[
1
:]
)
print
(
"Loading model..."
)
params
=
GptParams
(
interactive
=
True
,
interactive_start
=
True
,
top_k
=
10000
,
temp
=
0.2
,
repeat_penalty
=
1
,
n_threads
=
7
,
n_ctx
=
2048
,
antiprompt
=
[
"Question:"
,
"Observation:"
],
model
=
MODEL
,
input_prefix
=
" "
,
n_predict
=
-
1
,
prompt
=
prompt
,
)
with
LLaMAInteract
(
params
)
as
m
:
m
.
interact
()
Back
|
FazBrowse Home
|
New Git URL