Browse Source

Merge pull request #70 from DuckPaddle/patch-2

pull/82/head
Daniel Miessler 9 months ago committed by GitHub
parent
commit
b000264ae5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      client/fabric/fabric.py
  2. 20
      client/fabric/utils.py

2
client/fabric/fabric.py

@ -79,7 +79,7 @@ def main():
if args.text is not None: if args.text is not None:
text = args.text text = args.text
else: else:
text = sys.stdin.read() text = standalone.get_cli_input()
if args.stream: if args.stream:
standalone.streamMessage(text) standalone.streamMessage(text)
else: else:

20
client/fabric/utils.py

@ -3,6 +3,7 @@ import os
from openai import OpenAI from openai import OpenAI
import pyperclip import pyperclip
import sys import sys
import platform
from dotenv import load_dotenv from dotenv import load_dotenv
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
from tqdm import tqdm from tqdm import tqdm
@ -175,6 +176,25 @@ class Standalone:
else: else:
print(f"Failed to fetch models: HTTP {response.status_code}") print(f"Failed to fetch models: HTTP {response.status_code}")
def get_cli_input(self):
""" aided by ChatGPT; uses platform library
accepts either piped input or console input
from either Windows or Linux
Args:
none
Returns:
string from either user or pipe
"""
system = platform.system()
if system == 'Windows':
if not sys.stdin.isatty(): # Check if input is being piped
return sys.stdin.readline().strip() # Read piped input
else:
return input("Enter Question: ") # Prompt user for input from console
else:
return sys.stdin.read()
class Update: class Update:
def __init__(self): def __init__(self):

Loading…
Cancel
Save