-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: make it easier to run model providers with standalone GPTScript
After this change, running standalone GPTScript with one of these model providers will prompt for the proper credential. Signed-off-by: Donnie Adams <[email protected]>
- Loading branch information
Showing
11 changed files
with
40 additions
and
19 deletions.
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
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
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
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
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
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,29 @@ | ||
import os | ||
import json | ||
import asyncio | ||
from gptscript import GPTScript, Options | ||
|
||
|
||
if os.getenv("OBOT_RUN_ID") is not None: | ||
# This is being run from Obot, and we shouldn't prompt for the credential. | ||
# The credential should have been set up outside of this, so just error. | ||
print("The credential has not been properly configured") | ||
exit(1) | ||
|
||
if os.getenv("ENV_VARS") is None: | ||
print("No environment variables provided for prompting") | ||
exit(1) | ||
|
||
|
||
async def main(): | ||
g = GPTScript() | ||
env_vars = dict() | ||
|
||
for env in os.getenv("ENV_VARS").split(","): | ||
out = await g.run("sys.prompt", Options(input=f'{{"message":"Please enter the value for {env}", "env":"{env}", "fields":"{env}","sensitive":"true"}}')).text() | ||
env_vars.update(json.loads(out)) | ||
|
||
print(json.dumps({"env": env_vars})) | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
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 @@ | ||
git+https://github.com/gptscript-ai/py-gptscript.git@0cebee3afa51b8c56006e479a990c262bd693ba6#egg=gptscript |
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,7 +1,5 @@ | ||
Name: Placeholder credential | ||
Description: This is a fake credential tool for the model and auth providers. These credentials are handled in Obot and this tool should never be called. | ||
Parameters: env_vars: A list of environment variables to prompt for | ||
|
||
#!/bin/bash | ||
|
||
echo "The credential has not been properly configured" | ||
exit 1 | ||
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/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
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
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