Replies: 1 comment
-
I worked it out : Step 1 - pip install pgpt-python - allows python to talk to PrivateGPT API Step 2 - Create local python file with following in it to drive via the API Step 3 - execute pyton file via python .py ( needs python 3.10 or higher ) from pgpt_python.client import PrivateGPTApi print(client.health.health()) with open(" /home/testuser/Documents/testdoc.txt", "rb") as f: chunks_result = client.context_chunks.chunks_retrieval(text="how to change car oil") result = client.contextual_completions.prompt_completion( print("\n>Contextual completion:") |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
This might sound simple but I'm struggling to get it to work.
I'm a beginner, and am finding the API doco hard going, and really want to get PrivateGPT up and going , as I just want to do a simple query against an already ingested document.
Can I suggest adding to the doco a simple "How To" recipe for this, as many people probably are not API experts. This will help with more people using PrivateGPT I think.
So I'm trying to replicate if I was using the GUI -
Step 1 - choose the Search mode
Step 2 type in a query "What colour is the sky?
I have already ingested a document using the GUI called doc1.txt that I will be searching through.
What Ive done ( from ubuntu terminal ) running python 3.11 :
(1) pip install gradio_client
(2) created a python file with following text in it :
from gradio_client import Client, file
client = Client("http://localhost:8001/")
result = client.predict(
mode="Search",
api_name="/_set_current_mode"
)
client.predict(
history_with_input=None,
param_2="what colour is the sky?,",
param_3=Search,
param_4=None,
api_name="/_stream_fn_1"
)
(3) executed the python file and keep getting this error :
Loaded as API: http://localhost:8001/ ✔
Traceback (most recent call last):
File "/home/test/Documents/test3.py", line 10, in
client.predict(
File "/home/test/.pyenv/versions/3.11.11/lib/python3.11/site-packages/gradio_client/client.py", line 476, in predict
return self.submit(
^^^^^^^^^^^^
File "/home/test/.pyenv/versions/3.11.11/lib/python3.11/site-packages/gradio_client/client.py", line 520, in submit
args = utils.construct_args(endpoint.parameters_info, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/test/.pyenv/versions/3.11.11/lib/python3.11/site-packages/gradio_client/utils.py", line 1243, in construct_args
raise ValueError(
ValueError: This endpoint does not support key-word arguments Please click on 'view API' in the footer of the Gradio app to see usage.
If someone could tell me what I'm doing wrong and help me get this going, that would be great. Thanks in advance....
Beta Was this translation helpful? Give feedback.
All reactions