This file contains hidden or 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
| Respuesta de Gemini-exp-1114: | |
| Let's break down this Python code snippet step-by-step, focusing on its purpose, functionality, and the key concepts it employs. | |
| Purpose: |
This file contains hidden or 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
| import boto3 | |
| from botocore.exceptions import ClientError | |
| import json # Added import for json | |
| def create_public_s3_file(bucket_name: str, file_path: str, object_key: str) -> bool: | |
| """ | |
| Creates an S3 bucket (if it doesn't exist), uploads a file, and makes it publicly accessible. | |
| Args: | |
| bucket_name: The name of the S3 bucket. |
This file contains hidden or 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
| from fastapi import FastAPI | |
| app = FastAPI() | |
| @app.get("/") | |
| def read_root(): | |
| return {"Hello1": "World"} | |
| @app.get("/items/") | |
| def read_items(): |
This file contains hidden or 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
| import os | |
| import openai | |
| from openai.embeddings_utils import get_embedding, cosine_similarity | |
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| from ast import literal_eval | |
| import nomic | |
| from nomic import atlas |
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 hidden or 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
| const few_shot_text = `Bot: Ask me any question. | |
| Me: Can I ask you something about programming?. | |
| Bot: Yes, of course. Tell me your question and I will answer it | |
| Me: My question about Javascript is: Write a JavaScript function to apply Bubble Sort algorithm. | |
| Bot: | |
| Here is a JavaScript function to apply Bubble Sort algorithm: | |
| function bubbleSort(arr) { | |
| let swapped; | |
| do { | |
| swapped = false; |
This file contains hidden or 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
| const one_shot_text = 'Bot: Ask me any question. '+ | |
| 'Me: Can I ask you something about programming?. '+ | |
| 'Bot: Yes, of course. Tell me your question and I will answer it. '+ | |
| 'Me: My question about Javascript is: Write a JavaScript function to apply Bubble Sort algorithm.'+ | |
| 'Bot:'; | |
| async function main() { | |
| const completion = await openai.createCompletion({ | |
| model: "text-davinci-003", | |
| prompt: one_shot_text, | |
| temperature: 0, |
This file contains hidden or 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
| const zero_shot_text = 'Write a function in Javascript'; | |
| async function main() { | |
| const completion = await openai.createCompletion({ | |
| model: "text-davinci-003", | |
| prompt: zero_shot_text, | |
| temperature: 0.3, | |
| max_tokens: 100, | |
| top_p: 1.0, | |
| frequency_penalty: 0.5, | |
| presence_penalty: 0.0, |
This file contains hidden or 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
| #rds | |
| rds = boto3.client('rds', region_name='us-east-1') | |
| # Obtenemos una lista de todas las instancias RDS | |
| rds_instances = rds.describe_db_instances() | |
| stopRdsInstances = [] | |
| #recorremos las instancias y filtramos por tag | |
| for rds_instance in rds_instances["DBInstances"]: | |
| tags = rds.list_tags_for_resource(ResourceName=rds_instance["DBInstanceArn"]) |
This file contains hidden or 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
| # Definimos nuestro tag | |
| tag_name = 'Staging' | |
| #instancias EC2 | |
| ec2 = boto3.resource('ec2', region_name='us-east-1') | |
| instances = ec2.instances.filter(Filters=[ | |
| { | |
| 'Name': 'instance-state-name', | |
| 'Values': ['running'] |