Skip to content

Commit

Permalink
Fix invalid response generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Simatwa committed Jan 5, 2024
1 parent 8aca304 commit 49b9561
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
7 changes: 6 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@

**What's new?**
- Check version - `--version`
- Minor fixes.
- Minor fixes.

## v0.1.3

**What's new?**
- Invalid response - **fixed**
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://github.com/Simatwa/python-tgpt/actions/workflows/python-test.yml"><img src="https://github.com/Simatwa/python-tgpt/actions/workflows/python-test.yml/badge.svg" alt="Python Test"/></a>
-->
<a href="https://github.com/Simatwa/python-tgpt/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/static/v1?logo=GPL&color=Blue&message=MIT&label=License"/></a>
<a href="https://pypi.org/project/python-tgpt"><img alt="PyPi" src="https://img.shields.io/static/v1?logo=pypi&label=Pypi&message=v0.1.2&color=green"/></a>
<a href="https://pypi.org/project/python-tgpt"><img alt="PyPi" src="https://img.shields.io/static/v1?logo=pypi&label=Pypi&message=v0.1.3&color=green"/></a>
<a href="https://github.com/psf/black"><img alt="Black" src="https://img.shields.io/static/v1?logo=Black&label=Code-style&message=Black"/></a>
<a href="#"><img alt="Passing" src="https://img.shields.io/static/v1?logo=Docs&label=Docs&message=Passing&color=green"/></a>
<a href="https://github.com/Simatwa/python-tgpt/actions/workflows/python-package.yml"><img src="https://github.com/Simatwa/python-tgpt/actions/workflows/python-package.yml/badge.svg"/></a>
Expand Down Expand Up @@ -42,7 +42,7 @@ python-tgpt

This project enables seamless interaction with [LLaMA](https://ai.meta.com/llama/) AI without requiring an API Key.

The name *python-tgpt* draws inspiration from its parent project [tgpt](https://github.com/aandrew-me/tgpt), which operates on [Golang](https://go.dev/). Through this Python adaptation, users can effortlessly engage with LLaMA's capabilities, fostering a smoother AI interaction experience.
The name *python-tgpt* draws inspiration from its parent project [tgpt](https://github.com/aandrew-me/tgpt), which operates on [Golang](https://go.dev/). Through this Python adaptation, users can effortlessly engage with LLaMA's capabilities *(alias **LEO** by Brave)*, fostering a smoother AI interaction experience.

### Features

Expand All @@ -64,7 +64,7 @@ The name *python-tgpt* draws inspiration from its parent project [tgpt](https://

### Installation

Download binaries for your system from [here.](https://github.com/Simatwa/python-tgpt/releases/tag/v0.1.2)
Download binaries for your system from [here.](https://github.com/Simatwa/python-tgpt/releases/tag/v0.1.3)

Alternatively, you can install non-binaries. *(Recommended)*

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="python-tgpt",
version="0.1.2",
version="0.1.3",
license="MIT",
author="Smartwa",
maintainer="Smartwa",
Expand Down
2 changes: 1 addition & 1 deletion tgpt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .utils import Conversation
from .utils import AwesomePrompts

__version__ = "0.1.2"
__version__ = "0.1.3"
__author__ = "Smartwa"
__repo__ = "https://github.com/Simatwa/python-tgpt"

Expand Down
11 changes: 10 additions & 1 deletion tgpt/tgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(
self.last_response = {}
self.headers = {
"Content-Type": "application/json",
"accept": "text/event-stream",
"x-brave-key": brave_key,
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/110.0",
}
Expand All @@ -76,6 +77,14 @@ def __init__(
)
self.conversation.history_offset = history_offset
session.proxies = proxies
self.system_prompt = (
"\n\nYour name is Leo, a helpful"
"respectful and honest AI assistant created by the company Brave. You will be replying to a user of the Brave browser. "
"Always respond in a neutral tone. Be polite and courteous. Answer concisely in no more than 50-80 words."
"\n\nPlease ensure that your responses are socially unbiased and positive in nature."
"If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. "
"If you don't know the answer to a question, please don't share false information.\n"
)

def ask(
self,
Expand Down Expand Up @@ -122,7 +131,7 @@ def ask(
payload = {
"max_tokens_to_sample": self.max_tokens_to_sample,
"model": self.model,
"prompt": f"[INST] {conversation_prompt} [/INST]",
"prompt": f"<s>[INST] <<SYS>>{self.system_prompt}<</SYS>>{conversation_prompt} [/INST]",
"self.stop_sequence": self.stop_sequences,
"stream": stream,
"top_k": self.top_k,
Expand Down

2 comments on commit 49b9561

@sameedzahoor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with the word limit (60-80 words) ?

@Simatwa
Copy link
Owner Author

@Simatwa Simatwa commented on 49b9561 Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is that located?

Please sign in to comment.