-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prompt manager integrated and working with 6 tests * Updated templates to for prompt-template update
- Loading branch information
1 parent
51aef6c
commit 1e13776
Showing
19 changed files
with
647 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
test-prompt-... is tested with this prompt set... | ||
|
||
prompt-template \ | ||
-p pulsar://localhost:6650 \ | ||
--system-prompt 'You are a {{attitude}}, you are called {{name}}' \ | ||
--global-term \ | ||
'name=Craig' \ | ||
'attitude=LOUD, SHOUTY ANNOYING BOT' \ | ||
--prompt \ | ||
'question={{question}}' \ | ||
'french-question={{question}}' \ | ||
"analyze=Find the name and age in this text, and output a JSON structure containing just the name and age fields: {{description}}. Don't add markup, just output the raw JSON object." \ | ||
"graph-query=Study the following knowledge graph, and then answer the question.\\n\nGraph:\\n{% for edge in knowledge %}({{edge.0}})-[{{edge.1}}]->({{edge.2}})\\n{%endfor%}\\nQuestion:\\n{{question}}" \ | ||
"extract-definition=Analyse the text provided, and then return a list of terms and definitions. The output should be a JSON array, each item in the array is an object with fields 'term' and 'definition'.Don't add markup, just output the raw JSON object. Here is the text:\\n{{text}}" \ | ||
--prompt-response-type \ | ||
'question=text' \ | ||
'analyze=json' \ | ||
'graph-query=text' \ | ||
'extract-definition=json' \ | ||
--prompt-term \ | ||
'question=name:Bonny' \ | ||
'french-question=attitude:French-speaking bot' \ | ||
--prompt-schema \ | ||
'analyze={ "type" : "object", "properties" : { "age": { "type" : "number" }, "name": { "type" : "string" } } }' \ | ||
'extract-definition={ "type": "array", "items": { "type": "object", "properties": { "term": { "type": "string" }, "definition": { "type": "string" } }, "required": [ "term", "definition" ] } }' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pulsar | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
chunk = """I noticed a cat in my garden. It is a four-legged animal | ||
which is a mammal and can be tame or wild. I wonder if it will be friends | ||
with me. I think the cat's name is Fred and it has 4 legs""" | ||
|
||
resp = p.request_topics( | ||
chunk=chunk, | ||
) | ||
|
||
for d in resp: | ||
print(d.topic) | ||
print(" ", d.definition) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
description = """Fred is a 4-legged cat who is 12 years old""" | ||
|
||
resp = p.request( | ||
id="analyze", | ||
terms = { | ||
"description": description, | ||
} | ||
) | ||
|
||
print(json.dumps(resp, indent=4)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
chunk=""" | ||
The Space Shuttle was a reusable spacecraft that transported astronauts and cargo to and from Earth's orbit. It was designed to launch like a rocket, maneuver in orbit like a spacecraft, and land like an airplane. The Space Shuttle was NASA's space transportation system and was used for many purposes, including: | ||
Carrying astronauts | ||
The Space Shuttle could carry up to seven astronauts at a time. | ||
Launching, recovering, and repairing satellites | ||
The Space Shuttle could launch satellites into orbit, recover them, and repair them. | ||
Building the International Space Station | ||
The Space Shuttle carried large parts into space to build the International Space Station. | ||
Conducting research | ||
Astronauts conducted experiments in the Space Shuttle, which was like a science lab in space. | ||
The Space Shuttle was retired in 2011 after the Columbia accident in 2003. The Columbia Accident Investigation Board report found that the Space Shuttle was unsafe and expensive to make safe. | ||
Here are some other facts about the Space Shuttle: | ||
The Space Shuttle was 184 ft tall and had a diameter of 29 ft. | ||
The Space Shuttle had a mass of 4,480,000 lb. | ||
The Space Shuttle's first flight was on April 12, 1981. | ||
The Space Shuttle's last mission was in 2011. | ||
""" | ||
|
||
q = "Tell me some facts in the knowledge graph" | ||
|
||
resp = p.request( | ||
id="extract-definition", | ||
terms = { | ||
"text": chunk, | ||
} | ||
) | ||
|
||
print(resp) | ||
|
||
for fact in resp: | ||
print(fact["term"], "::") | ||
print(fact["definition"]) | ||
print() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pulsar | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
question = """What is the square root of 16?""" | ||
|
||
resp = p.request( | ||
id="french-question", | ||
terms = { | ||
"question": question | ||
} | ||
) | ||
|
||
print(resp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
knowledge = [ | ||
("accident", "evoked", "a wide range of deeply felt public responses"), | ||
("Space Shuttle concept", "had", "genesis"), | ||
("Commission", "had", "a mandate to develop recommendations for corrective or other action based upon the Commission's findings and determinations"), | ||
("Commission", "established", "teams of persons"), | ||
("Space Shuttle Challenger", "http://www.w3.org/2004/02/skos/core#definition", "A space shuttle that was destroyed in an accident during mission 51-L."), | ||
("The mid fuselage", "contains", "the payload bay"), | ||
("Volume I", "contains", "Chapter IX"), | ||
("accident", "resulted in", "firm national resolve that those men and women be forever enshrined in the annals of American heroes"), | ||
("Volume I", "contains", "Chapter VII"), | ||
("Volume I", "contains", "Chapter II"), | ||
("Volume I", "contains", "Chapter V"), | ||
("Commission", "believes", "its investigation and report have been responsive to the request of the President and hopes that they will serve the best interests of the nation in restoring the United States space program to its preeminent position in the world"), | ||
("Commission", "construe", "mandate"), | ||
("accident", "became", "a milestone on the way to achieving the full potential that space offers to mankind"), | ||
("Volume I", "contains", "The Commission"), | ||
("Commission", "http://www.w3.org/2004/02/skos/core#definition", "A group established to investigate the space shuttle accident"), | ||
("Volume I", "contains", "Appendix D"), | ||
("Commission", "had", "a mandate to review the circumstances surrounding the accident to establish the probable cause or causes of the accident"), | ||
("Volume I", "contains", "Recommendations") | ||
] | ||
|
||
q = "Tell me some facts in the knowledge graph" | ||
|
||
resp = p.request( | ||
id="graph-query", | ||
terms = { | ||
"name": "Jayney", | ||
"knowledge": knowledge, | ||
"question": q | ||
} | ||
) | ||
|
||
print(resp) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pulsar | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
question = """What is the square root of 16?""" | ||
|
||
resp = p.request( | ||
id="question", | ||
terms = { | ||
"question": question | ||
} | ||
) | ||
|
||
print(resp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pulsar | ||
from trustgraph.clients.prompt_client import PromptClient | ||
|
||
p = PromptClient(pulsar_host="pulsar://localhost:6650") | ||
|
||
question = """What is the square root of 16?""" | ||
|
||
resp = p.request( | ||
id="question", | ||
terms = { | ||
"question": question, | ||
"attitude": "Spanish-speaking bot" | ||
} | ||
) | ||
|
||
print(resp) | ||
|
Oops, something went wrong.