Spaces:
Running
Running
Commit
·
3d0e1d3
1
Parent(s):
501ef44
Add langsmith
Browse files- app.py +13 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import solara
|
| 2 |
from typing import Any, Callable, Optional, TypeVar, Union, cast, overload, List
|
| 3 |
from typing_extensions import TypedDict
|
|
@@ -13,6 +16,10 @@ from pydantic import BaseModel, Field
|
|
| 13 |
from graphviz import Digraph
|
| 14 |
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# NEEDED FOR INPUT TEXT AREA INSTEAD OF INPUT TEXT
|
| 17 |
def use_change(el: reacton.core.Element, on_value: Callable[[Any], Any], enabled=True):
|
| 18 |
"""Trigger a callback when a blur events occurs or the enter key is pressed."""
|
|
@@ -76,7 +83,12 @@ def InputTextarea(
|
|
| 76 |
|
| 77 |
# EXTRACTION
|
| 78 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
class Node(BaseModel):
|
| 82 |
id: int
|
|
|
|
| 1 |
+
#from dotenv import load_dotenv, find_dotenv
|
| 2 |
+
#_ = load_dotenv(find_dotenv())
|
| 3 |
+
|
| 4 |
import solara
|
| 5 |
from typing import Any, Callable, Optional, TypeVar, Union, cast, overload, List
|
| 6 |
from typing_extensions import TypedDict
|
|
|
|
| 16 |
from graphviz import Digraph
|
| 17 |
|
| 18 |
|
| 19 |
+
|
| 20 |
+
from langsmith import traceable
|
| 21 |
+
from langsmith.wrappers import wrap_openai
|
| 22 |
+
|
| 23 |
# NEEDED FOR INPUT TEXT AREA INSTEAD OF INPUT TEXT
|
| 24 |
def use_change(el: reacton.core.Element, on_value: Callable[[Any], Any], enabled=True):
|
| 25 |
"""Trigger a callback when a blur events occurs or the enter key is pressed."""
|
|
|
|
| 83 |
|
| 84 |
# EXTRACTION
|
| 85 |
openai.api_key = os.environ['OPENAI_API_KEY']
|
| 86 |
+
|
| 87 |
+
# Wrap the OpenAI client with LangSmith
|
| 88 |
+
client = wrap_openai(OpenAI())
|
| 89 |
+
|
| 90 |
+
# Patch the client with instructor
|
| 91 |
+
client = instructor.from_openai(client, mode=instructor.Mode.TOOLS)
|
| 92 |
|
| 93 |
class Node(BaseModel):
|
| 94 |
id: int
|
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ solara==1.31.0
|
|
| 2 |
openai==1.17.0
|
| 3 |
instructor==1.1.0
|
| 4 |
graphviz==0.20.3
|
|
|
|
|
|
| 2 |
openai==1.17.0
|
| 3 |
instructor==1.1.0
|
| 4 |
graphviz==0.20.3
|
| 5 |
+
langsmith==0.1.47
|