Skip to content

Commit

Permalink
add contexnt (system prompt)
Browse files Browse the repository at this point in the history
  • Loading branch information
hitsmaxft committed Jan 21, 2024
1 parent 0040d92 commit cfbc19a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 3 additions & 4 deletions gemini-cli-example.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
token=PUT_TOUR_TOKEN_HERE
token="PUT_TOUR_TOKEN_HERE"

[generation_config]
top_p=0.95
top_k=20
top_p = 0.95
top_k = 20
candidate_count=1
max_output_tokens=2000
stop_sequences=["STOP!"]

11 changes: 9 additions & 2 deletions gemini_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ def main():
parser = argparse.ArgumentParser(description="Stream responses from Google Generative AI.")
parser.add_argument('prompt', type=str, help="Prompt to send to the model", nargs='?', default=None)
parser.add_argument('-t', '--token', type=str, help="API token for authentication", default=None)
parser.add_argument('-s', '--context', type=str, help="context(system) prompt, optional", default=None)
parser.add_argument('-f', '--config-file', type=str, help="Path to the config file", default='~/.gemini-cli.toml')
args = parser.parse_args()



# 读取 prompt,支持从命令行参数或 stdin
if args.prompt is not False:
prompt = args.prompt if args.prompt is not True else sys.stdin.read().strip()
if not prompt:
print("No prompt provided. Please provide a prompt to generate content.")
parser.print_help()
sys.exit(1)
else:
parser.print_help()
return
Expand All @@ -77,7 +80,11 @@ def main():

# 读取 token,支持从命令行参数或配置文件
token = args.token if args.token is not None else config.get("token", None)
context = args.context if args.context is not None else config.get("context", None)
if token:
if context:
prompt = f"Context: {context}\n{prompt}"

stream_generate_content(prompt, token, config.get("generation_config", None))
else:
print("Token not found. Please provide a token via --token argument or ensure your token is correctly set in ~/.gemini-cli.toml.")
Expand Down

0 comments on commit cfbc19a

Please sign in to comment.