Skip to content

Commit 49b9561

Browse files
committed
Fix invalid response generation
1 parent 8aca304 commit 49b9561

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

docs/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@
7171

7272
**What's new?**
7373
- Check version - `--version`
74-
- Minor fixes.
74+
- Minor fixes.
75+
76+
## v0.1.3
77+
78+
**What's new?**
79+
- Invalid response - **fixed**

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<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>
99
-->
1010
<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>
11-
<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>
11+
<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>
1212
<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>
1313
<a href="#"><img alt="Passing" src="https://img.shields.io/static/v1?logo=Docs&label=Docs&message=Passing&color=green"/></a>
1414
<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>
@@ -42,7 +42,7 @@ python-tgpt
4242

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

45-
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.
45+
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.
4646

4747
### Features
4848

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

6565
### Installation
6666

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

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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="python-tgpt",
15-
version="0.1.2",
15+
version="0.1.3",
1616
license="MIT",
1717
author="Smartwa",
1818
maintainer="Smartwa",

tgpt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .utils import Conversation
55
from .utils import AwesomePrompts
66

7-
__version__ = "0.1.2"
7+
__version__ = "0.1.3"
88
__author__ = "Smartwa"
99
__repo__ = "https://github.com/Simatwa/python-tgpt"
1010

tgpt/tgpt.py

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

8089
def ask(
8190
self,
@@ -122,7 +131,7 @@ def ask(
122131
payload = {
123132
"max_tokens_to_sample": self.max_tokens_to_sample,
124133
"model": self.model,
125-
"prompt": f"[INST] {conversation_prompt} [/INST]",
134+
"prompt": f"<s>[INST] <<SYS>>{self.system_prompt}<</SYS>>{conversation_prompt} [/INST]",
126135
"self.stop_sequence": self.stop_sequences,
127136
"stream": stream,
128137
"top_k": self.top_k,

0 commit comments

Comments
 (0)