Skip to content

Commit

Permalink
Clarity tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
uogbuji committed Nov 30, 2023
1 parent 6797b8e commit 873a953
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ llm_api = openai_chat_api(base_url='http://localhost:8000') # Update for your L
prompt = 'Write a short birthday greeting for my star employee'

# You can set model params as needed
resp = llm_api(prompt_to_chat(prompt), temperature=0.1, max_tokens=100)
resp = llm_api(prompt_to_chat(prompt), temperature=0.1, max_tokens=256)
# Extract just the response text, but the entire structure is available
print(llm_api.first_choice_message(resp))
```
Expand Down
5 changes: 3 additions & 2 deletions demo/chat_web_selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
Needs access to an OpenAI-like service. Default assumption is self-hosted
via e.g. llama-cpp-python or text-generation-webui
Assume for the following it's at host my-llm-host, port 8000
Assume for the following it's at host localhost, port 8000.
MAKE SURE YOU USE A WORKING SERVER BECAUSE THIS IS A DEMO & THE ERROR HANDLING IS SIMPLISTIC
pip install prerequisites, in addition to OgbujiPT cloned dir:
click sentence_transformers qdrant-client httpx html2text amara3.xml
```sh
python demo/chat_web_selects.py --apibase http://my-llm-host:8000 "www.newworldencyclopedia.org/entry/Igbo_People"
python demo/chat_web_selects.py --apibase http://localhost:8000 "www.newworldencyclopedia.org/entry/Igbo_People"
```
An example question might be "Who are the neighbors of the Igbo people?"
Expand Down
5 changes: 4 additions & 1 deletion pylib/embedding/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ def update(self, texts, metas=None):
# The inline prints actually turn into a cool progress indicator in jupyter 😁
embeddings = list(map(float, self._embedding_model.encode(text)))

payload = dict(_text=text, **meta)
try:
payload = dict(_text=text, **meta)
except TypeError:
raise TypeError('metas must be a list of mappings (dicts)')

# Upsert the embedded chunk and its payload into the collection
self.db.upsert(
Expand Down
7 changes: 5 additions & 2 deletions pylib/llm_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ def __call__(self, prompt, api_func=None, **kwargs):
Args:
prompt (str): Prompt to send to the LLM
kwargs (dict, optional): Extra parameters to pass to the model via API
kwargs (dict, optional): Extra parameters to pass to the model via API.
See Completions.create in OpenAI API, but in short, these:
best_of, echo, frequency_penalty, logit_bias, logprobs, max_tokens, n
presence_penalty, seed, stop, stream, suffix, temperature, top_p, user
Returns:
dict: JSON response from the LLM
'''
Expand Down

0 comments on commit 873a953

Please sign in to comment.