Skip to content

Instantly share code, notes, and snippets.

from h2o_wave import main, app, Q, ui, on, run_on, data
@app('/')
async def serve(q: Q):
print(q.args)
print(q.events)
# First time a browser comes to the app
if not q.client.initialized:
await initialize_client_session(q)
@mtanco
mtanco / export_import.py
Created June 10, 2024 17:13
Download all collection data upload all collection data
import os
from h2ogpte import H2OGPTE
EMAIL = "[email protected]"
client = H2OGPTE(
address='https://playground.h2ogpte.h2o.ai',
api_key='sk-',
)
from h2o_wave import main, app, Q, ui, on, run_on, data
@app('/')
async def serve(q: Q):
print(q.args)
# First time a browser comes to the app
if not q.client.initialized:
await initialize_client_session(q)
@mtanco
mtanco / long_running_tasks.py
Created June 4, 2024 16:02
Wave long running task
from h2o_wave import main, app, Q, ui, on, handle_on
@app('/')
async def serve(q: Q):
# First time a browser comes to the app
if not q.client.initialized:
await init(q)
q.client.initialized = True
@mtanco
mtanco / att.css
Created April 24, 2024 19:02
Example for chatbots, waiting dialogs, and custom CSS
[data-test="header"] {
background: #000000 !important;
}
/* will be used by default for buttons*/
.ms-Button--default {
background-color: #6c757d;
color: #FFFFFF;
border-color: #6c757d;
border-radius: 2rem;
}
@mtanco
mtanco / documents.py
Created April 24, 2024 17:38
Render files as pdfs.
from h2o_wave import main, app, Q, ui
import os
from docx import Document
from openpyxl import load_workbook
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.lib import colors
# from msgpy import MSG
@mtanco
mtanco / pdf.py
Created March 15, 2024 21:18
How to render PDFs in Apps
from h2o_wave import main, app, Q, ui
@app('/')
async def serve(q: Q):
q.page["meta"] = ui.meta_card(
box="",
layouts=[
ui.layout(
@mtanco
mtanco / h2ogpte_history.py
Created March 6, 2024 19:33
Example of an h2oGPTe chatbot wave app that keeps user history and shares this with the LLM
import os
import asyncio
from h2o_wave import main, app, Q, ui, data, run_on, on
from h2ogpte import H2OGPTE
from h2ogpte.types import ChatMessage, PartialChatMessage, SessionError
from h2ogpte.errors import UnauthorizedError
from loguru import logger
@mtanco
mtanco / llm_python_code_generator.py
Created March 5, 2024 19:02
Testing system prompts, models, and specific ways of asking questions to understand how to get Python Executable code from an LLM
"""
Code Executing Testing from LLMs
Michelle Tanco - [email protected]
March 4, 2024
We are attempting to get executable Python code from an LLM. This testing suite helps us with that process.
"""
import os
from h2ogpte import H2OGPTE
from h2ogpte.types import SessionError
@mtanco
mtanco / stream_h2o_llms.py
Last active January 10, 2024 00:52
This script serves as a foundation for creating interactive chatbot applications with streaming responses powered by H2O.ai's language models within the H2O Wave framework.
import os
import asyncio
from h2o_wave import main, app, Q, ui, data, run_on, on
from h2ogpte import H2OGPTE
from h2ogpte.types import ChatMessage, PartialChatMessage
SYSTEM_PROMPT = "Hello, I am a bot that only talks about dogs!"