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

masenf/0.2.7-updates #144

Merged
merged 3 commits into from
Sep 7, 2023
Merged
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
3 changes: 1 addition & 2 deletions chatroom/chatroom/chatroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def index() -> rx.Component:

async def broadcast_event(name: str, payload: t.Dict[str, t.Any] = {}) -> None:
"""Simulate frontend event with given name and payload from all clients."""
event_ns = app.sio.namespace_handlers["/event"]
responses = []
for state in app.state_manager.states.values():
async for update in state._process(
Expand All @@ -104,7 +103,7 @@ async def broadcast_event(name: str, payload: t.Dict[str, t.Any] = {}) -> None:
):
# Emit the event.
responses.append(
event_ns.emit(
app.event_namespace.emit(
str(rx.constants.SocketEvent.EVENT), update.json(), to=state.get_sid()
),
)
Expand Down
6 changes: 4 additions & 2 deletions dalle/dalle/dalle.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Welcome to Pynecone! This file outlines the steps to create a basic app."""
import reflex as rx
import os

import openai
import reflex as rx

openai.api_key = "YOUR_API_KEY"
openai.api_key = os.environ["OPENAI_API_KEY"]


class State(rx.State):
Expand Down
9 changes: 6 additions & 3 deletions gpt/gpt/gpt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Welcome to Reflex! This app is a demonstration of OpenAI's GPT."""
import datetime
import os

import openai
import reflex as rx

from .helpers import navbar
import openai
import datetime

openai.api_key = "YOUR_API_KEY"
openai.api_key = os.environ["OPENAI_API_KEY"]
MAX_QUESTIONS = 10


Expand Down
13 changes: 13 additions & 0 deletions sales/sales/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import reflex as rx


class Customer(rx.Model, table=True):
"""The customer model."""

customer_name: str
email: str
age: int
gender: str
location: str
job: str
salary: int
24 changes: 8 additions & 16 deletions sales/sales/sales.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import reflex as rx
import openai

openai.api_key = "YOUR_OPENAI_API_KEY"
products = {'T-shirt': { 'description': 'A plain white t-shirt made of 100% cotton.', 'price': 10.99 }, 'Jeans': { 'description': 'A pair of blue denim jeans with a straight leg fit.', 'price': 24.99 }, 'Hoodie': { 'description': 'A black hoodie made of a cotton and polyester blend.', 'price': 34.99 }, 'Cardigan': { 'description': 'A grey cardigan with a V-neck and long sleeves.', 'price': 36.99 }, 'Joggers': { 'description': 'A pair of black joggers made of a cotton and polyester blend.', 'price': 44.99 }, 'Dress': { 'description': 'A black dress made of 100% polyester.', 'price': 49.99 }, 'Jacket': { 'description': 'A navy blue jacket made of 100% cotton.', 'price': 55.99 }, 'Skirt': { 'description': 'A brown skirt made of a cotton and polyester blend.', 'price': 29.99 }, 'Shorts': { 'description': 'A pair of black shorts made of a cotton and polyester blend.', 'price': 19.99 }, 'Sweater': { 'description': 'A white sweater with a crew neck and long sleeves.', 'price': 39.99}}
import os

import openai
import reflex as rx

class Customer(rx.Model, table=True):
"""The customer model."""
from .models import Customer

customer_name: str
email: str
age: int
gender: str
location: str
job: str
salary: int
openai.api_key = os.environ["OPENAI_API_KEY"]
products = {'T-shirt': { 'description': 'A plain white t-shirt made of 100% cotton.', 'price': 10.99 }, 'Jeans': { 'description': 'A pair of blue denim jeans with a straight leg fit.', 'price': 24.99 }, 'Hoodie': { 'description': 'A black hoodie made of a cotton and polyester blend.', 'price': 34.99 }, 'Cardigan': { 'description': 'A grey cardigan with a V-neck and long sleeves.', 'price': 36.99 }, 'Joggers': { 'description': 'A pair of black joggers made of a cotton and polyester blend.', 'price': 44.99 }, 'Dress': { 'description': 'A black dress made of 100% polyester.', 'price': 49.99 }, 'Jacket': { 'description': 'A navy blue jacket made of 100% cotton.', 'price': 55.99 }, 'Skirt': { 'description': 'A brown skirt made of a cotton and polyester blend.', 'price': 29.99 }, 'Shorts': { 'description': 'A pair of black shorts made of a cotton and polyester blend.', 'price': 19.99 }, 'Sweater': { 'description': 'A white sweater with a crew neck and long sleeves.', 'price': 39.99}}


class State(rx.State):
Expand Down Expand Up @@ -106,7 +98,7 @@ def generate_email(
self.generate_email_data["salary"] = salary
self.text_area_disabled = True
self.gen_response = True
return self.call_openai
return State.call_openai



Expand Down Expand Up @@ -308,7 +300,7 @@ def index():


# Add state and page to the app.
app = rx.App(state=State)
app = rx.App(state=State, admin_dash=rx.AdminDash(models=[Customer]))
app.add_page(index)
app.add_page(add_customer, "/onboarding")
app.compile()