-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. init project.
- Loading branch information
Showing
7 changed files
with
74 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# see bard.google.com -> F12 -> Application -> Cookies (https://bard.google.com) -> __Secure-1PSID | ||
BARD_PROXY_API_KEY={your-bard-key} |
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,3 @@ | ||
.idea | ||
.vscode | ||
*.so |
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,17 @@ | ||
# 使用 Python 3.8 作为基础镜像 | ||
FROM python:3.8 | ||
|
||
# 将当前目录下的文件复制到容器的 /app 目录中 | ||
COPY . /app | ||
|
||
# 设置工作目录为 /app | ||
WORKDIR /app | ||
|
||
# 安装依赖包 | ||
RUN pip install -r requirements.txt | ||
|
||
# 暴露容器的端口 | ||
EXPOSE 8671 | ||
|
||
# 运行应用 | ||
CMD ["python", "main.py"] |
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 |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# Bard-Proxy | ||
A proxy for Bard LLM | ||
Proxy for Bard LLM | ||
|
||
## How to get your bard key | ||
|
||
Access from <a ref="https://bard.google.com/">Bard</a> | ||
|
||
<p align="left"> | ||
<img src="./assets/bard_key.png" width="600px" /> | ||
</p> | ||
|
||
|
||
## Quick Start | ||
|
||
### Method 1: Quick Start by Docker | ||
|
||
```commandline | ||
# use your own bard key 'YOUR-BARD-KEY' instead. | ||
docker run -p 8671:8671 -e BARD_PROXY_API_KEY=YOUR-BARD-KEY bard_proxy | ||
``` | ||
|
||
### Method 2: Start In Current Project | ||
1. set your bard key in .env file | ||
2. start python project | ||
> python main.py | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,24 @@ | ||
import os | ||
from flask import Flask, request | ||
import bardapi | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
app = Flask(__name__) | ||
|
||
token = os.getenv("BARD_PROXY_API_KEY", "Not config") | ||
|
||
|
||
@app.route('/api/openai/v1/chat/completions', methods=['POST']) | ||
def do_request(): | ||
print(f'token={token}') | ||
input_text = request.json.get('input') | ||
response = bardapi.core.Bard(token).get_answer(input_text) | ||
if response and response.get('content'): | ||
return response['content'] | ||
return f"bard request error: response={str(response)}" | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0', port=8671) |
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,3 @@ | ||
bardapi==0.1.29 | ||
flask | ||
python-dotenv |