Spaces:
Runtime error
Runtime error
modi req and app
Browse filesFiles changed (2)
- app.py+35-1
- requirements.txt+2-1
32 unmodified lines3334353637383940414243444532 unmodified linestranscripts = open(filename, "r").readlines()return transcriptsdef puzzle(message, history):if len(history)==0 or history[-1][1] == 'Wrong starting input!':current_folder = Path(__file__).parentFILE_PATH = current_folder / 'puzzle.txt'# transcripts = read_file(FILE_PATH)transcripts = read_file('puzzle.txt')input_text = random.choice(transcripts)puzzle_and_ans = generate_puzzle(input_text)32 unmodified lines333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787932 unmodified linestranscripts = open(filename, "r").readlines()return transcriptsimport boto3import osdef read_s3_file(bucket_name, file_key):"""Read a file from an S3 bucket.:param bucket_name: Name of the S3 bucket.:param file_key: Key of the file in the S3 bucket.:return: File content as a string."""# Initialize a session using Amazon S3session = boto3.Session(aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),region_name='us-east-2')# Create an S3 clients3 = session.client('s3')try:# Fetch the fileobj = s3.get_object(Bucket=bucket_name, Key=file_key)# Read the file contentcontent = obj['Body'].read().decode('utf-8')return contentexcept Exception as e:print(f"Error fetching file from S3: {e}")return Nonedef puzzle(message, history):if len(history)==0 or history[-1][1] == 'Wrong starting input!':current_folder = Path(__file__).parentFILE_PATH = current_folder / 'puzzle.txt'# transcripts = read_file(FILE_PATH)transcripts = read_s3_file('riley-mlops-course', 'puzzles.txt').split('\n')input_text = random.choice(transcripts)puzzle_and_ans = generate_puzzle(input_text)
123gradio==3.44.4gradio_client==0.5.1openai1234gradio==3.44.4gradio_client==0.5.1openaiboto3
app.py+35-1
requirements.txt+2-1