Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add donaciones link footer #162

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@

# A small copyright notice for the page footer (in HTML).
# (translatable)
CONTENT_FOOTER = '<span>Contents &copy; {date} <a href="mailto:{email}">{author}</a> - Powered by <a href="https://getnikola.com" rel="nofollow" target="_blanc">Nikola</a> {license}</span><span><a href="" rel="nofollow" target="_blanc">Aporta a PyAr con tu donación<a/></span>'
CONTENT_FOOTER = '<span>Contents &copy; {date} <a href="mailto:{email}">{author}</a> - Powered by <a href="https://getnikola.com" rel="nofollow" target="_blanc">Nikola</a> {license}</span><span><a href="https://ac.python.org.ar/#donaciones" rel="nofollow" target="_blanc">Aporta a PyAr con tu donación<a/></span>'

# Things that will be passed to CONTENT_FOOTER.format(). This is done
# for translatability, as dicts are not formattable. Nikola will
Expand Down
11 changes: 11 additions & 0 deletions scrap_y_chroma/chroma_http_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import chromadb

cliente = chromadb.HttpClient(host='127.0.0.1', port=8010)


collection = cliente.get_collection('pyar_searchbar_collection')

print(collection.query(
query_texts='hola python',
include=['documents', 'metadatas']
))
75 changes: 75 additions & 0 deletions scrap_y_chroma/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
API REST en Flask
Instrucciones para Windows:
1. Instalar waitress: pip install waitress
2. Ejecutar la aplicación: waitress-serve --port=3000 app:app

@autor: Martinez, Nicolas Agustin
"""
# Importación de módulos necesarios

from flask import Flask, request, jsonify, render_template
from flask_cors import CORS
import webbrowser, chromadb

# Inicialización de la aplicación Flask
app = Flask(__name__)


@app.route('/')
def index():
return render_template('index.html')

@app.route('/pyar_search', methods=['POST'])
def query_abc():
"""
Endpoint para obtener similitudes basadas en el texto proporcionado.

Entrada: JSON con el campo 'text'
Salida: JSON con las similitudes encontradas o un objeto JSON vacío en caso de error


"""
collection_name = 'pyar_searchbar_collection'
collection = client.get_collection(collection_name)

# Obtener datos del cuerpo de la solicitud
#data:dict = request.json
#print('DENTRO DE query_abc() EN APP.py')
data = request.json
print('data:', data)
# Si no hay datos, retornar None
if not data:
return None

# Extraer el texto del JSON
pregunta:str = data['pregunta']

# Intentar obtener similitudes y devolver la respuesta
try:
response:chromadb.QueryResult = collection.query(
query_texts=pregunta,
n_results=5,
include=['documents', 'metadatas', 'distances'])

#return response
print(response)
return jsonify(response)

except Exception as e:
# Imprimir el error y devolver un objeto JSON vacío
print('Error al obtener similitudes:', e)
return {}

if __name__ == '__main__':
#webbrowser.open('http://localhost:8010')

client = chromadb.HttpClient(host='127.0.0.1', port=8010)
# Habilitación de CORS para la aplicación

CORS(app)

# (Opcional) Para montar la API en línea, descomentar la siguiente línea
# run_with_ngrok(app)

app.run(host='localhost', port=5500, debug=True)
Loading