theRealNG commited on
Commit
f9c4aab
Β·
unverified Β·
2 Parent(s): edbc3471f39bb8

Merge pull request #34 from beautiful-code/supabase_connect

Browse files
Files changed (33) hide show
  1. .env.example +8 -3
  2. __init__.py β†’ app/__init__.py +0 -0
  3. {tests β†’ app/api_endpoints}/__init__.py +0 -0
  4. {workflows β†’ app/lib}/__init__.py +0 -0
  5. app/lib/supabase_client.py +26 -0
  6. app/tests/__init__.py +0 -0
  7. {tests β†’ app/tests}/til_test.py +1 -1
  8. app/ui/__init__.py +0 -0
  9. {ui β†’ app/ui}/course_learn_suggest_expectations.py +2 -2
  10. {ui β†’ app/ui}/main.css +0 -0
  11. {ui β†’ app/ui}/til_feedback.py +3 -3
  12. app/utils/__init__.py +0 -0
  13. {utils β†’ app/utils}/endpoints_utils.py +0 -0
  14. {utils β†’ app/utils}/settings.py +0 -0
  15. {utils β†’ app/utils}/write_to_json.py +0 -0
  16. app/workflows/__init__.py +0 -0
  17. {workflows β†’ app/workflows}/article_suggestion.py +0 -0
  18. {workflows β†’ app/workflows}/courses/expectation_revision.py +0 -0
  19. {workflows β†’ app/workflows}/courses/lessons_extractor.py +0 -0
  20. {workflows β†’ app/workflows}/courses/suggest_check_question.py +0 -0
  21. {workflows β†’ app/workflows}/courses/suggest_expectations.py +0 -0
  22. {workflows β†’ app/workflows}/research_article_suggester.py +0 -0
  23. {workflows β†’ app/workflows}/til/analyse_til.py +0 -0
  24. {workflows β†’ app/workflows}/til/analyse_til_v2.py +0 -0
  25. {workflows β†’ app/workflows}/til/rewrite_til_v2.py +0 -0
  26. {workflows β†’ app/workflows}/til/suggest_headlines_v2.py +0 -0
  27. {workflows β†’ app/workflows}/tools/helpers.py +0 -0
  28. {workflows β†’ app/workflows}/tools/scrape_website.py +0 -0
  29. {workflows β†’ app/workflows}/tools/search_web.py +0 -0
  30. {workflows β†’ app/workflows}/utils/feedback.py +10 -4
  31. endpoints.py +51 -41
  32. requirements.txt +3 -0
  33. ui_main.py +3 -3
.env.example CHANGED
@@ -1,11 +1,16 @@
1
  OPENAI_API_KEY=""
2
- OPENAI_MODEL="gpt-3.5-turbo"
3
  GOOGLE_API_KEY=""
4
 
5
  LANGCHAIN_TRACING_V2=true
6
  LANGCHAIN_API_KEY=""
7
  LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
8
- LANGCHAIN_PROJECT="growthy-agents"
9
 
10
- TAVILY_API_KEY=""
11
  ENV="local"
 
 
 
 
 
 
 
1
  OPENAI_API_KEY=""
2
+ OPENAI_MODEL="gpt-4o-mini"
3
  GOOGLE_API_KEY=""
4
 
5
  LANGCHAIN_TRACING_V2=true
6
  LANGCHAIN_API_KEY=""
7
  LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
8
+ LANGCHAIN_PROJECT="customer_agent"
9
 
 
10
  ENV="local"
11
+
12
+ SUPABASE_URL_STAGING=""
13
+ SUPABASE_KEY_STAGING=""
14
+
15
+ SUPABASE_URL_PROD=""
16
+ SUPABASE_KEY_PROD=""
__init__.py β†’ app/__init__.py RENAMED
File without changes
{tests β†’ app/api_endpoints}/__init__.py RENAMED
File without changes
{workflows β†’ app/lib}/__init__.py RENAMED
File without changes
app/lib/supabase_client.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import UUID4
2
+ from supabase import create_client
3
+ import os
4
+
5
+ FEEDBACK_TABLE_NAME = "llm_feedback"
6
+
7
+
8
+ class SupabaseClient:
9
+ def __init__(self):
10
+ url = os.environ.get("SUPABASE_URL")
11
+ key = os.environ.get("SUPABASE_KEY")
12
+ self.client = create_client(url, key)
13
+
14
+ def post_feedback(self, run_id: UUID4, metric_type: str, metric_score: float, sub_workflow: str):
15
+ try:
16
+ response = self.client.table(FEEDBACK_TABLE_NAME).insert({
17
+ "run_id": str(run_id),
18
+ "sub_workflow": sub_workflow,
19
+ "metric_type": metric_type,
20
+ "metric_score": metric_score,
21
+ }).execute()
22
+ print("Response: ", response)
23
+ return response
24
+ except Exception as exception:
25
+ print("Exception: ", exception)
26
+ return exception
app/tests/__init__.py ADDED
File without changes
{tests β†’ app/tests}/til_test.py RENAMED
@@ -1,5 +1,5 @@
1
  import pytest
2
- from growthy_agents.crew.til import TilCrew # type: ignore
3
 
4
 
5
  examples = [
 
1
  import pytest
2
+ from app.workflows.til.analyse_til import TilCrew # type: ignore
3
 
4
 
5
  examples = [
app/ui/__init__.py ADDED
File without changes
{ui β†’ app/ui}/course_learn_suggest_expectations.py RENAMED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
- from workflows.courses.suggest_expectations import SuggestExpectations, Inputs as ExpectationsInputs, Expectation
3
  from streamlit_extras.stylable_container import stylable_container
4
- from workflows.courses.expectation_revision import ExpectationRevision
5
 
6
 
7
 
 
1
  import streamlit as st
2
+ from app.workflows.courses.suggest_expectations import SuggestExpectations, Inputs as ExpectationsInputs, Expectation
3
  from streamlit_extras.stylable_container import stylable_container
4
+ from app.workflows.courses.expectation_revision import ExpectationRevision
5
 
6
 
7
 
{ui β†’ app/ui}/main.css RENAMED
File without changes
{ui β†’ app/ui}/til_feedback.py RENAMED
@@ -1,9 +1,9 @@
1
  import streamlit as st
2
  from dotenv import load_dotenv
3
- from workflows.til.analyse_til import TilCrew
4
- from workflows.til.analyse_til_v2 import AnalyseTilV2
5
  from streamlit_extras.capture import stdout
6
- from workflows.utils.feedback import Feedback
7
 
8
  load_dotenv()
9
 
 
1
  import streamlit as st
2
  from dotenv import load_dotenv
3
+ from app.workflows.til.analyse_til import TilCrew
4
+ from app.workflows.til.analyse_til_v2 import AnalyseTilV2
5
  from streamlit_extras.capture import stdout
6
+ from app.workflows.utils.feedback import Feedback
7
 
8
  load_dotenv()
9
 
app/utils/__init__.py ADDED
File without changes
{utils β†’ app/utils}/endpoints_utils.py RENAMED
File without changes
{utils β†’ app/utils}/settings.py RENAMED
File without changes
{utils β†’ app/utils}/write_to_json.py RENAMED
File without changes
app/workflows/__init__.py ADDED
File without changes
{workflows β†’ app/workflows}/article_suggestion.py RENAMED
File without changes
{workflows β†’ app/workflows}/courses/expectation_revision.py RENAMED
File without changes
{workflows β†’ app/workflows}/courses/lessons_extractor.py RENAMED
File without changes
{workflows β†’ app/workflows}/courses/suggest_check_question.py RENAMED
File without changes
{workflows β†’ app/workflows}/courses/suggest_expectations.py RENAMED
File without changes
{workflows β†’ app/workflows}/research_article_suggester.py RENAMED
File without changes
{workflows β†’ app/workflows}/til/analyse_til.py RENAMED
File without changes
{workflows β†’ app/workflows}/til/analyse_til_v2.py RENAMED
File without changes
{workflows β†’ app/workflows}/til/rewrite_til_v2.py RENAMED
File without changes
{workflows β†’ app/workflows}/til/suggest_headlines_v2.py RENAMED
File without changes
{workflows β†’ app/workflows}/tools/helpers.py RENAMED
File without changes
{workflows β†’ app/workflows}/tools/scrape_website.py RENAMED
File without changes
{workflows β†’ app/workflows}/tools/search_web.py RENAMED
File without changes
{workflows β†’ app/workflows}/utils/feedback.py RENAMED
@@ -1,6 +1,7 @@
1
  from pydantic import BaseModel, UUID4
2
  from typing import List, Optional
3
  from langsmith import Client
 
4
 
5
  class Feedback(BaseModel):
6
  metric_type: Optional[str]
@@ -32,12 +33,17 @@ class NewFeedback(BaseModel):
32
  run_id = inputs["run_id"]
33
  sub_workflow = inputs["sub_workflow"]
34
 
35
- # make a call to supabase
36
- self._post_to_supbase()
37
-
38
  self._post_to_langsmith(run_id)
39
 
40
- def _post_to_supbase(self):
 
 
 
 
 
 
 
41
  return
42
 
43
  def _post_to_langsmith(self, run_id: UUID4):
 
1
  from pydantic import BaseModel, UUID4
2
  from typing import List, Optional
3
  from langsmith import Client
4
+ from app.lib.supabase_client import SupabaseClient
5
 
6
  class Feedback(BaseModel):
7
  metric_type: Optional[str]
 
33
  run_id = inputs["run_id"]
34
  sub_workflow = inputs["sub_workflow"]
35
 
36
+ self._post_to_supbase(run_id, sub_workflow)
 
 
37
  self._post_to_langsmith(run_id)
38
 
39
+ def _post_to_supbase(self, run_id: UUID4, sub_worfklow: str):
40
+ client = SupabaseClient()
41
+ client.post_feedback(
42
+ run_id= run_id,
43
+ sub_workflow= sub_worfklow,
44
+ metric_score=self.metric_score,
45
+ metric_type=self.metric_type
46
+ )
47
  return
48
 
49
  def _post_to_langsmith(self, run_id: UUID4):
endpoints.py CHANGED
@@ -1,27 +1,37 @@
1
  from dotenv import load_dotenv
2
  load_dotenv()
3
 
4
- from .workflows.til.suggest_headlines_v2 import SuggestHeadlinesV2, Response as SuggestHeadlinesResponse
5
- from .workflows.til.rewrite_til_v2 import RewriteTilV2, Response as RewriteTilResponse
6
- from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs, Response as ExpectationRevisionResponse
7
- from .workflows.courses.suggest_check_question import SuggestCheckQuestion, Inputs as SuggestCheckQuestionInputs, Response as SuggestCheckQuestionResponse
8
- from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectation, Response as SuggestExpectationsResponse
9
- from .workflows.til.analyse_til import TilCrew, TilFeedbackResponse
10
- from .workflows.til.analyse_til_v2 import AnalyseTilV2, TilV2FeedbackResponse
11
- from .workflows.utils.feedback import Feedback, post_feedback, NewFeedback
12
- from .utils.endpoints_utils import CreateTilInputs
13
  from fastapi import FastAPI
14
  from fastapi.middleware.cors import CORSMiddleware
15
  from pydantic import UUID4
16
  from tempenv import TemporaryEnvironment
17
  from typing import List
 
18
  import uvicorn
19
 
20
 
21
- LANGSMITH_STAGING_PROJECT = "customer_agent"
22
- LANGSMITH_PROD_PROJECT = "growthy-agents"
23
- LANGSMITH_STAGING_MODEL = "gpt-4o-mini"
24
- LANGSMITH_PROD_MODEL = "gpt-4o"
 
 
 
 
 
 
 
 
 
25
 
26
  description = """
27
  API helps you do awesome stuff. πŸš€
@@ -73,7 +83,7 @@ async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
73
 
74
  @app.post("/staging/til_feedback", tags=["til_feedback", "staging"])
75
  async def staging_til_feedback_kickoff(content: List[str]) -> TilFeedbackResponse:
76
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
77
  separator = "\n* "
78
  content[0] = "* " + content[0]
79
  inputs = {"content": separator.join(content)}
@@ -83,7 +93,7 @@ async def staging_til_feedback_kickoff(content: List[str]) -> TilFeedbackRespons
83
 
84
  @app.post("/staging/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
85
  async def staging_capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
86
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
87
  post_feedback(run_id=run_id, feedback=feedback)
88
  return "ok"
89
 
@@ -96,12 +106,12 @@ def til_v2_analyze_logic(content) -> TilV2FeedbackResponse:
96
 
97
  @app.post("/v2/til_feedback", tags=["til_feedback"])
98
  async def til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
99
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
100
  return til_v2_analyze_logic(content)
101
 
102
  @app.post("/v2/til_feedback/{run_id}/feedback", tags=["til_feedback"])
103
  async def capture_til_v2_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
104
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
105
  feedback.post({"run_id": run_id, "sub_workflow": "til_analysis"})
106
  return "ok"
107
 
@@ -109,20 +119,20 @@ async def capture_til_v2_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
109
 
110
  @app.post("/staging/v2/til_feedback", tags=["til_feedback", "staging"])
111
  async def staging_til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
112
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
113
  return til_v2_analyze_logic(content)
114
 
115
 
116
  @app.post("/staging/v2/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
117
  async def staging_capture_til_v2_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
118
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_MODEL, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
119
  feedback.post({"run_id": run_id, "sub_workflow": "til_analysis"})
120
  return "ok"
121
 
122
 
123
  @app.post("/v2/til_rewrite", tags=["til_readability"])
124
  async def til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
125
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
126
  inputs = CreateTilInputs(content)
127
  result = RewriteTilV2().kickoff(inputs)
128
  return result
@@ -130,14 +140,14 @@ async def til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
130
 
131
  @app.post("/v2/til_rewrite/{run_id}/feedback", tags=["til_readability"])
132
  async def capture_til_v2_rewrite_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
133
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
134
  feedback.post({"run_id": run_id, "sub_workflow": "til_understandability"})
135
  return "ok"
136
 
137
 
138
  @app.post("/staging/v2/til_rewrite", tags=["til_readability", "staging"])
139
  async def staging_til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
140
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
141
  inputs = CreateTilInputs(content)
142
  result = RewriteTilV2().kickoff(inputs)
143
  return result
@@ -145,14 +155,14 @@ async def staging_til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilRespon
145
 
146
  @app.post("/staging/v2/til_rewrite/{run_id}/feedback", tags=["til_readability", "staging"])
147
  async def staging_capture_til_v2_rewrite_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
148
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
149
  feedback.post({"run_id": run_id, "sub_workflow": "til_understandability"})
150
  return "ok"
151
 
152
 
153
  @app.post("/v2/til_headlines", tags=["til_headlines"])
154
  async def til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
155
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
156
  inputs = CreateTilInputs(content)
157
  result = SuggestHeadlinesV2().kickoff(inputs)
158
  return result
@@ -160,14 +170,14 @@ async def til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesRespon
160
 
161
  @app.post("/v2/til_headlines/{run_id}/feedback", tags=["til_headlines"])
162
  async def capture_til_v2_headlines(run_id: UUID4, feedback: NewFeedback) -> str:
163
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
164
  feedback.post({"run_id": run_id, "sub_workflow": "til_headline"})
165
  return "ok"
166
 
167
 
168
  @app.post("/staging/v2/til_headlines", tags=["til_headlines", "staging"])
169
  async def staging_til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
170
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
171
  inputs = CreateTilInputs(content)
172
  result = SuggestHeadlinesV2().kickoff(inputs)
173
  return result
@@ -175,7 +185,7 @@ async def staging_til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlin
175
 
176
  @app.post("/staging/v2/til_headlines/{run_id}/feedback", tags=["til_headlines", "staging"])
177
  async def staging_capture_til_v2_headlines(run_id: UUID4, feedback: NewFeedback) -> str:
178
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_MODEL, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
179
  feedback.post({"run_id": run_id, "sub_workflow": "til_headline"})
180
  return "ok"
181
 
@@ -203,25 +213,25 @@ def course_learn_suggest_expectations_feedback_logic(run_id: UUID4, feedback: Fe
203
 
204
  @app.post("/course_learn/suggest_expectations", tags=["course_learn"])
205
  async def course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
206
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
207
  return course_learn_suggest_expectations_logic(inputs)
208
 
209
 
210
  @app.post("/staging/course_learn/suggest_expectations", tags=["course_learn", "staging"])
211
  async def staging_course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
212
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
213
  return course_learn_suggest_expectations_logic(inputs)
214
 
215
 
216
  @app.post("/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn"])
217
  async def capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
218
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
219
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
220
 
221
 
222
  @app.post("/staging/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn", "staging"])
223
  async def staging_capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
224
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
225
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
226
 
227
 
@@ -237,13 +247,13 @@ def course_learn_expectation_revision_logic(inputs: ExpectationRevisionInputs) -
237
 
238
  @app.post("/course_learn/expectation_revision", tags=["course_learn"])
239
  async def course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
240
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
241
  return course_learn_expectation_revision_logic(inputs)
242
 
243
 
244
  @app.post("/staging/course_learn/expectation_revision", tags=["course_learn", "staging"])
245
  async def staging_course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
246
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
247
  return course_learn_expectation_revision_logic(inputs)
248
 
249
 
@@ -256,13 +266,13 @@ def capture_expectation_revision_feedback_logic(run_id: UUID4, feedback: Feedbac
256
 
257
  @app.post("/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn"])
258
  async def capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
259
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
260
  return capture_expectation_revision_feedback_logic(run_id, feedback)
261
 
262
 
263
  @app.post("/staging/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn", "staging"])
264
  async def staging_capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
265
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
266
  return capture_expectation_revision_feedback_logic(run_id, feedback)
267
 
268
 
@@ -279,13 +289,13 @@ def course_learn_suggest_check_question_logic(inputs: SuggestCheckQuestionInputs
279
 
280
  @app.post("/course_learn/suggest_check_question", tags=["course_learn"])
281
  async def course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
282
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
283
  return course_learn_suggest_check_question_logic(inputs)
284
 
285
 
286
  @app.post("/staging/course_learn/suggest_check_question", tags=["course_learn", "staging"])
287
  async def staging_course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
288
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
289
  return course_learn_suggest_check_question_logic(inputs)
290
 
291
 
@@ -298,26 +308,26 @@ def course_learn_suggest_check_question_feedback_logic(run_id: UUID4, feedback:
298
 
299
  @app.post("/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn"])
300
  async def course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
301
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
302
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
303
 
304
 
305
  @app.post("/staging/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn", "staging"])
306
  async def staging_course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
307
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
308
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
309
 
310
 
311
  @app.post("/llm_feedback/{run_id}/feedback", tags=["llm_feedback"])
312
  async def capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
313
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
314
  post_feedback(run_id=run_id, feedback=feedback)
315
  return "ok"
316
 
317
 
318
  @app.post("/staging/llm_feedback/{run_id}/feedback", tags=["llm_feedback", "staging"])
319
  async def staging_capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
320
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
321
  post_feedback(run_id=run_id, feedback=feedback)
322
  return "ok"
323
 
 
1
  from dotenv import load_dotenv
2
  load_dotenv()
3
 
4
+ from app.workflows.til.suggest_headlines_v2 import SuggestHeadlinesV2, Response as SuggestHeadlinesResponse
5
+ from app.workflows.til.rewrite_til_v2 import RewriteTilV2, Response as RewriteTilResponse
6
+ from app.workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs, Response as ExpectationRevisionResponse
7
+ from app.workflows.courses.suggest_check_question import SuggestCheckQuestion, Inputs as SuggestCheckQuestionInputs, Response as SuggestCheckQuestionResponse
8
+ from app.workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectation, Response as SuggestExpectationsResponse
9
+ from app.workflows.til.analyse_til import TilCrew, TilFeedbackResponse
10
+ from app.workflows.til.analyse_til_v2 import AnalyseTilV2, TilV2FeedbackResponse
11
+ from app.workflows.utils.feedback import Feedback, post_feedback, NewFeedback
12
+ from app.utils.endpoints_utils import CreateTilInputs
13
  from fastapi import FastAPI
14
  from fastapi.middleware.cors import CORSMiddleware
15
  from pydantic import UUID4
16
  from tempenv import TemporaryEnvironment
17
  from typing import List
18
+ import os
19
  import uvicorn
20
 
21
 
22
+ STAGING_ENV_CONFIG = {
23
+ "LANGCHAIN_PROJECT": "customer_agent",
24
+ "OPENAI_MODEL": "gpt-4o-mini",
25
+ "SUPABASE_URL": os.environ["SUPABASE_URL_STAGING"],
26
+ "SUPABASE_KEY": os.environ["SUPABASE_KEY_STAGING"]
27
+ }
28
+
29
+ PROD_ENV_CONFIG = {
30
+ "LANGCHAIN_PROJECT": "growthy-agents-prod",
31
+ "OPENAI_MODEL": "gpt-4o",
32
+ "SUPABASE_URL": os.environ["SUPABASE_URL_PROD"],
33
+ "SUPABASE_KEY": os.environ["SUPABASE_KEY_PROD"]
34
+ }
35
 
36
  description = """
37
  API helps you do awesome stuff. πŸš€
 
83
 
84
  @app.post("/staging/til_feedback", tags=["til_feedback", "staging"])
85
  async def staging_til_feedback_kickoff(content: List[str]) -> TilFeedbackResponse:
86
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
87
  separator = "\n* "
88
  content[0] = "* " + content[0]
89
  inputs = {"content": separator.join(content)}
 
93
 
94
  @app.post("/staging/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
95
  async def staging_capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
96
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
97
  post_feedback(run_id=run_id, feedback=feedback)
98
  return "ok"
99
 
 
106
 
107
  @app.post("/v2/til_feedback", tags=["til_feedback"])
108
  async def til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
109
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
110
  return til_v2_analyze_logic(content)
111
 
112
  @app.post("/v2/til_feedback/{run_id}/feedback", tags=["til_feedback"])
113
  async def capture_til_v2_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
114
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
115
  feedback.post({"run_id": run_id, "sub_workflow": "til_analysis"})
116
  return "ok"
117
 
 
119
 
120
  @app.post("/staging/v2/til_feedback", tags=["til_feedback", "staging"])
121
  async def staging_til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
122
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
123
  return til_v2_analyze_logic(content)
124
 
125
 
126
  @app.post("/staging/v2/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
127
  async def staging_capture_til_v2_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
128
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
129
  feedback.post({"run_id": run_id, "sub_workflow": "til_analysis"})
130
  return "ok"
131
 
132
 
133
  @app.post("/v2/til_rewrite", tags=["til_readability"])
134
  async def til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
135
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
136
  inputs = CreateTilInputs(content)
137
  result = RewriteTilV2().kickoff(inputs)
138
  return result
 
140
 
141
  @app.post("/v2/til_rewrite/{run_id}/feedback", tags=["til_readability"])
142
  async def capture_til_v2_rewrite_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
143
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
144
  feedback.post({"run_id": run_id, "sub_workflow": "til_understandability"})
145
  return "ok"
146
 
147
 
148
  @app.post("/staging/v2/til_rewrite", tags=["til_readability", "staging"])
149
  async def staging_til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
150
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
151
  inputs = CreateTilInputs(content)
152
  result = RewriteTilV2().kickoff(inputs)
153
  return result
 
155
 
156
  @app.post("/staging/v2/til_rewrite/{run_id}/feedback", tags=["til_readability", "staging"])
157
  async def staging_capture_til_v2_rewrite_feedback(run_id: UUID4, feedback: NewFeedback) -> str:
158
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
159
  feedback.post({"run_id": run_id, "sub_workflow": "til_understandability"})
160
  return "ok"
161
 
162
 
163
  @app.post("/v2/til_headlines", tags=["til_headlines"])
164
  async def til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
165
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
166
  inputs = CreateTilInputs(content)
167
  result = SuggestHeadlinesV2().kickoff(inputs)
168
  return result
 
170
 
171
  @app.post("/v2/til_headlines/{run_id}/feedback", tags=["til_headlines"])
172
  async def capture_til_v2_headlines(run_id: UUID4, feedback: NewFeedback) -> str:
173
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
174
  feedback.post({"run_id": run_id, "sub_workflow": "til_headline"})
175
  return "ok"
176
 
177
 
178
  @app.post("/staging/v2/til_headlines", tags=["til_headlines", "staging"])
179
  async def staging_til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
180
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
181
  inputs = CreateTilInputs(content)
182
  result = SuggestHeadlinesV2().kickoff(inputs)
183
  return result
 
185
 
186
  @app.post("/staging/v2/til_headlines/{run_id}/feedback", tags=["til_headlines", "staging"])
187
  async def staging_capture_til_v2_headlines(run_id: UUID4, feedback: NewFeedback) -> str:
188
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
189
  feedback.post({"run_id": run_id, "sub_workflow": "til_headline"})
190
  return "ok"
191
 
 
213
 
214
  @app.post("/course_learn/suggest_expectations", tags=["course_learn"])
215
  async def course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
216
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
217
  return course_learn_suggest_expectations_logic(inputs)
218
 
219
 
220
  @app.post("/staging/course_learn/suggest_expectations", tags=["course_learn", "staging"])
221
  async def staging_course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
222
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
223
  return course_learn_suggest_expectations_logic(inputs)
224
 
225
 
226
  @app.post("/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn"])
227
  async def capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
228
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
229
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
230
 
231
 
232
  @app.post("/staging/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn", "staging"])
233
  async def staging_capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
234
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
235
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
236
 
237
 
 
247
 
248
  @app.post("/course_learn/expectation_revision", tags=["course_learn"])
249
  async def course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
250
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
251
  return course_learn_expectation_revision_logic(inputs)
252
 
253
 
254
  @app.post("/staging/course_learn/expectation_revision", tags=["course_learn", "staging"])
255
  async def staging_course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
256
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
257
  return course_learn_expectation_revision_logic(inputs)
258
 
259
 
 
266
 
267
  @app.post("/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn"])
268
  async def capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
269
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
270
  return capture_expectation_revision_feedback_logic(run_id, feedback)
271
 
272
 
273
  @app.post("/staging/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn", "staging"])
274
  async def staging_capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
275
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
276
  return capture_expectation_revision_feedback_logic(run_id, feedback)
277
 
278
 
 
289
 
290
  @app.post("/course_learn/suggest_check_question", tags=["course_learn"])
291
  async def course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
292
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
293
  return course_learn_suggest_check_question_logic(inputs)
294
 
295
 
296
  @app.post("/staging/course_learn/suggest_check_question", tags=["course_learn", "staging"])
297
  async def staging_course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
298
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
299
  return course_learn_suggest_check_question_logic(inputs)
300
 
301
 
 
308
 
309
  @app.post("/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn"])
310
  async def course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
311
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
312
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
313
 
314
 
315
  @app.post("/staging/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn", "staging"])
316
  async def staging_course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
317
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
318
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
319
 
320
 
321
  @app.post("/llm_feedback/{run_id}/feedback", tags=["llm_feedback"])
322
  async def capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
323
+ with TemporaryEnvironment(PROD_ENV_CONFIG):
324
  post_feedback(run_id=run_id, feedback=feedback)
325
  return "ok"
326
 
327
 
328
  @app.post("/staging/llm_feedback/{run_id}/feedback", tags=["llm_feedback", "staging"])
329
  async def staging_capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
330
+ with TemporaryEnvironment(STAGING_ENV_CONFIG):
331
  post_feedback(run_id=run_id, feedback=feedback)
332
  return "ok"
333
 
requirements.txt CHANGED
@@ -3,8 +3,10 @@ asyncio
3
  crewai
4
  crewai_tools
5
  fastapi
 
6
  fastapi_cors
7
  langchain_community
 
8
  langchain_google_genai
9
  langchain_openai
10
  langchainhub
@@ -19,6 +21,7 @@ semanticscholar
19
  streamlit
20
  streamlit-extras
21
  streamlit_router
 
22
  tavily-python
23
  tempenv
24
  unstructured
 
3
  crewai
4
  crewai_tools
5
  fastapi
6
+ fastapi[standard]
7
  fastapi_cors
8
  langchain_community
9
+ fastapi[standard]
10
  langchain_google_genai
11
  langchain_openai
12
  langchainhub
 
21
  streamlit
22
  streamlit-extras
23
  streamlit_router
24
+ supabase
25
  tavily-python
26
  tempenv
27
  unstructured
ui_main.py CHANGED
@@ -1,7 +1,7 @@
1
  from dotenv import load_dotenv
2
  from streamlit_extras.stylable_container import stylable_container
3
- from ui.til_feedback import feedback_main
4
- from ui.course_learn_suggest_expectations import course_suggester_main
5
  import math
6
  import streamlit as st
7
  import subprocess
@@ -48,7 +48,7 @@ def show_main_page():
48
  '''
49
  st.markdown(page_bg_img, unsafe_allow_html=True)
50
 
51
- css = load_css("ui/main.css")
52
 
53
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
54
 
 
1
  from dotenv import load_dotenv
2
  from streamlit_extras.stylable_container import stylable_container
3
+ from app.ui.til_feedback import feedback_main
4
+ from app.ui.course_learn_suggest_expectations import course_suggester_main
5
  import math
6
  import streamlit as st
7
  import subprocess
 
48
  '''
49
  st.markdown(page_bg_img, unsafe_allow_html=True)
50
 
51
+ css = load_css("app/ui/main.css")
52
 
53
  st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)
54