theRealNG commited on
Commit
aa7685e
·
1 Parent(s): 52b64c6

endpoints(llm_feedback): add generic llm feedback endpoints

Browse files
Files changed (2) hide show
  1. endpoints.py +53 -54
  2. workflows/utils/feedback.py +3 -0
endpoints.py CHANGED
@@ -1,25 +1,27 @@
1
  from dotenv import load_dotenv
2
  load_dotenv()
3
 
4
- import uvicorn
5
- from typing import List
6
- from tempenv import TemporaryEnvironment
7
- from pydantic import UUID4
8
- from fastapi.middleware.cors import CORSMiddleware
 
 
 
 
9
  from fastapi import FastAPI
 
 
 
 
 
10
 
11
- from .utils.endpoints_utils import CreateTilInputs
12
- from .workflows.utils.feedback import Feedback, post_feedback
13
- from .workflows.til.analyse_til_v2 import AnalyseTilV2, TilV2FeedbackResponse
14
- from .workflows.til.analyse_til import TilCrew, TilFeedbackResponse
15
- from .workflows.courses.suggest_expectations import SuggestExpectations, Inputs as SuggestExpectationsInputs, Expectation, Response as SuggestExpectationsResponse
16
- from .workflows.courses.suggest_check_question import SuggestCheckQuestion, Inputs as SuggestCheckQuestionInputs, Response as SuggestCheckQuestionResponse
17
- from .workflows.courses.expectation_revision import ExpectationRevision, Inputs as ExpectationRevisionInputs, Response as ExpectationRevisionResponse
18
- from .workflows.til.rewrite_til_v2 import RewriteTilV2, Response as RewriteTilResponse
19
- from .workflows.til.suggest_headlines_v2 import SuggestHeadlinesV2, Response as SuggestHeadlinesResponse
20
 
21
  LANGSMITH_STAGING_PROJECT = "customer_agent"
22
  LANGSMITH_PROD_PROJECT = "growthy-agents"
 
 
23
 
24
  description = """
25
  API helps you do awesome stuff. 🚀
@@ -65,15 +67,13 @@ async def til_feedback_kickoff(content: List[str]) -> TilFeedbackResponse:
65
 
66
  @app.post("/til_feedback/{run_id}/feedback", tags=["til_feedback"])
67
  async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
68
- print("Metric Type: ", feedback.metric_type)
69
- print("Feedback On: ", feedback.feedback_on)
70
  post_feedback(run_id=run_id, feedback=feedback)
71
  return "ok"
72
 
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": "gpt-4o-mini"}):
77
  separator = "\n* "
78
  content[0] = "* " + content[0]
79
  inputs = {"content": separator.join(content)}
@@ -83,9 +83,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": "gpt-4o-mini"}):
87
- print("Metric Type: ", feedback.metric_type)
88
- print("Feedback On: ", feedback.feedback_on)
89
  post_feedback(run_id=run_id, feedback=feedback)
90
  return "ok"
91
 
@@ -98,56 +96,43 @@ def til_v2_analyze_logic(content) -> TilV2FeedbackResponse:
98
 
99
  @app.post("/v2/til_feedback", tags=["til_feedback"])
100
  async def til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
101
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
102
  return til_v2_analyze_logic(content)
103
 
104
 
105
  @app.post("/staging/v2/til_feedback", tags=["til_feedback", "staging"])
106
  async def staging_til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
107
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
108
  return til_v2_analyze_logic(content)
109
 
110
 
111
- @app.post("/v2/til_feedback/{run_id}/feedback", tags=["til_feedback"])
112
- async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
113
- print("Metric Type: ", feedback.metric_type)
114
- print("Feedback On: ", feedback.feedback_on)
115
- post_feedback(run_id=run_id, feedback=feedback)
116
- return "ok"
117
-
118
-
119
- @app.post("/staging/v2/til_feedback/{run_id}/feedback", tags=["til_feedback", "staging"])
120
- async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
121
- print("Metric Type: ", feedback.metric_type)
122
- print("Feedback On: ", feedback.feedback_on)
123
- post_feedback(run_id=run_id, feedback=feedback)
124
- return "ok"
125
-
126
-
127
  @app.post("/v2/til_rewrite", tags=["til_readability"])
128
  async def til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
129
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
130
  inputs = CreateTilInputs(content)
131
  result = RewriteTilV2().kickoff(inputs)
132
  return result
133
 
 
134
  @app.post("/staging/v2/til_rewrite", tags=["til_readability", "staging"])
135
  async def staging_til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
136
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
137
  inputs = CreateTilInputs(content)
138
  result = RewriteTilV2().kickoff(inputs)
139
  return result
140
 
 
141
  @app.post("/v2/til_headlines", tags=["til_headlines"])
142
  async def til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
143
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
144
  inputs = CreateTilInputs(content)
145
  result = SuggestHeadlinesV2().kickoff(inputs)
146
  return result
147
 
 
148
  @app.post("/staging/v2/til_headlines", tags=["til_headlines", "staging"])
149
  async def staging_til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
150
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
151
  inputs = CreateTilInputs(content)
152
  result = SuggestHeadlinesV2().kickoff(inputs)
153
  return result
@@ -174,25 +159,25 @@ def course_learn_suggest_expectations_feedback_logic(run_id: UUID4, feedback: Fe
174
 
175
  @app.post("/course_learn/suggest_expectations", tags=["course_learn"])
176
  async def course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
177
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
178
  return course_learn_suggest_expectations_logic(inputs)
179
 
180
 
181
  @app.post("/staging/course_learn/suggest_expectations", tags=["course_learn", "staging"])
182
  async def staging_course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
183
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
184
  return course_learn_suggest_expectations_logic(inputs)
185
 
186
 
187
  @app.post("/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn"])
188
  async def capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
189
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
190
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
191
 
192
 
193
  @app.post("/staging/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn", "staging"])
194
  async def staging_capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
195
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
196
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
197
 
198
 
@@ -208,13 +193,13 @@ def course_learn_expectation_revision_logic(inputs: ExpectationRevisionInputs) -
208
 
209
  @app.post("/course_learn/expectation_revision", tags=["course_learn"])
210
  async def course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
211
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
212
  return course_learn_expectation_revision_logic(inputs)
213
 
214
 
215
  @app.post("/staging/course_learn/expectation_revision", tags=["course_learn", "staging"])
216
  async def staging_course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
217
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
218
  return course_learn_expectation_revision_logic(inputs)
219
 
220
 
@@ -227,13 +212,13 @@ def capture_expectation_revision_feedback_logic(run_id: UUID4, feedback: Feedbac
227
 
228
  @app.post("/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn"])
229
  async def capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
230
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
231
  return capture_expectation_revision_feedback_logic(run_id, feedback)
232
 
233
 
234
  @app.post("/staging/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn", "staging"])
235
  async def staging_capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
236
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
237
  return capture_expectation_revision_feedback_logic(run_id, feedback)
238
 
239
 
@@ -250,13 +235,13 @@ def course_learn_suggest_check_question_logic(inputs: SuggestCheckQuestionInputs
250
 
251
  @app.post("/course_learn/suggest_check_question", tags=["course_learn"])
252
  async def course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
253
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
254
  return course_learn_suggest_check_question_logic(inputs)
255
 
256
 
257
  @app.post("/staging/course_learn/suggest_check_question", tags=["course_learn", "staging"])
258
  async def staging_course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
259
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
260
  return course_learn_suggest_check_question_logic(inputs)
261
 
262
 
@@ -269,16 +254,30 @@ def course_learn_suggest_check_question_feedback_logic(run_id: UUID4, feedback:
269
 
270
  @app.post("/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn"])
271
  async def course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
272
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": "gpt-4o"}):
273
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
274
 
275
 
276
  @app.post("/staging/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn", "staging"])
277
  async def staging_course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
278
- with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": "gpt-4o-mini"}):
279
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
280
 
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  @app.get("/healthcheck")
283
  async def read_root():
284
  return {"status": "ok"}
 
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
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. 🚀
 
67
 
68
  @app.post("/til_feedback/{run_id}/feedback", tags=["til_feedback"])
69
  async def capture_feedback(run_id: UUID4, feedback: Feedback) -> str:
 
 
70
  post_feedback(run_id=run_id, feedback=feedback)
71
  return "ok"
72
 
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
 
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
 
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
 
103
  @app.post("/staging/v2/til_feedback", tags=["til_feedback", "staging"])
104
  async def staging_til_v2_feedback_kickoff(content: List[str]) -> TilV2FeedbackResponse:
105
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
106
  return til_v2_analyze_logic(content)
107
 
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  @app.post("/v2/til_rewrite", tags=["til_readability"])
110
  async def til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
111
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
112
  inputs = CreateTilInputs(content)
113
  result = RewriteTilV2().kickoff(inputs)
114
  return result
115
 
116
+
117
  @app.post("/staging/v2/til_rewrite", tags=["til_readability", "staging"])
118
  async def staging_til_v2_rewrite_kickoff(content: List[str]) -> RewriteTilResponse:
119
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
120
  inputs = CreateTilInputs(content)
121
  result = RewriteTilV2().kickoff(inputs)
122
  return result
123
 
124
+
125
  @app.post("/v2/til_headlines", tags=["til_headlines"])
126
  async def til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
127
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
128
  inputs = CreateTilInputs(content)
129
  result = SuggestHeadlinesV2().kickoff(inputs)
130
  return result
131
 
132
+
133
  @app.post("/staging/v2/til_headlines", tags=["til_headlines", "staging"])
134
  async def staging_til_v2_suggest_headlines(content: List[str]) -> SuggestHeadlinesResponse:
135
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
136
  inputs = CreateTilInputs(content)
137
  result = SuggestHeadlinesV2().kickoff(inputs)
138
  return result
 
159
 
160
  @app.post("/course_learn/suggest_expectations", tags=["course_learn"])
161
  async def course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
162
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
163
  return course_learn_suggest_expectations_logic(inputs)
164
 
165
 
166
  @app.post("/staging/course_learn/suggest_expectations", tags=["course_learn", "staging"])
167
  async def staging_course_learn_suggest_expectations(inputs: SuggestExpectationsInputs) -> SuggestExpectationsResponse:
168
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
169
  return course_learn_suggest_expectations_logic(inputs)
170
 
171
 
172
  @app.post("/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn"])
173
  async def capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
174
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
175
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
176
 
177
 
178
  @app.post("/staging/course_learn/suggest_expectations/{run_id}/feedback", tags=["course_learn", "staging"])
179
  async def staging_capture_suggest_expectations_feedback(run_id: UUID4, feedback: Feedback) -> str:
180
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
181
  return course_learn_suggest_expectations_feedback_logic(run_id, feedback)
182
 
183
 
 
193
 
194
  @app.post("/course_learn/expectation_revision", tags=["course_learn"])
195
  async def course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
196
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
197
  return course_learn_expectation_revision_logic(inputs)
198
 
199
 
200
  @app.post("/staging/course_learn/expectation_revision", tags=["course_learn", "staging"])
201
  async def staging_course_learn_expectation_revision(inputs: ExpectationRevisionInputs) -> ExpectationRevisionResponse:
202
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
203
  return course_learn_expectation_revision_logic(inputs)
204
 
205
 
 
212
 
213
  @app.post("/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn"])
214
  async def capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
215
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
216
  return capture_expectation_revision_feedback_logic(run_id, feedback)
217
 
218
 
219
  @app.post("/staging/course_learn/expectation_revision/{run_id}/feedback", tags=["course_learn", "staging"])
220
  async def staging_capture_expectation_revision_feedback(run_id: UUID4, feedback: Feedback) -> str:
221
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
222
  return capture_expectation_revision_feedback_logic(run_id, feedback)
223
 
224
 
 
235
 
236
  @app.post("/course_learn/suggest_check_question", tags=["course_learn"])
237
  async def course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
238
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
239
  return course_learn_suggest_check_question_logic(inputs)
240
 
241
 
242
  @app.post("/staging/course_learn/suggest_check_question", tags=["course_learn", "staging"])
243
  async def staging_course_learn_suggest_check_question(inputs: SuggestCheckQuestionInputs) -> SuggestCheckQuestionResponse:
244
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
245
  return course_learn_suggest_check_question_logic(inputs)
246
 
247
 
 
254
 
255
  @app.post("/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn"])
256
  async def course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
257
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
258
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
259
 
260
 
261
  @app.post("/staging/course_learn/suggest_check_question/{run_id}/feedback", tags=["course_learn", "staging"])
262
  async def staging_course_learn_suggest_check_question_feedback(run_id: UUID4, feedback: Feedback) -> str:
263
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
264
  return course_learn_suggest_check_question_feedback_logic(run_id, feedback)
265
 
266
 
267
+ @app.post("/llm_feedback/{run_id}/feedback", tags=["llm_feedback"])
268
+ async def capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
269
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_PROD_PROJECT, "OPENAI_MODEL": LANGSMITH_PROD_MODEL}):
270
+ post_feedback(run_id=run_id, feedback=feedback)
271
+ return "ok"
272
+
273
+
274
+ @app.post("/staging/llm_feedback/{run_id}/feedback", tags=["llm_feedback", "staging"])
275
+ async def staging_capture_llm_feedback(run_id: UUID4, feedback: Feedback) -> str:
276
+ with TemporaryEnvironment({"LANGCHAIN_PROJECT": LANGSMITH_STAGING_PROJECT, "OPENAI_MODEL": LANGSMITH_STAGING_MODEL}):
277
+ post_feedback(run_id=run_id, feedback=feedback)
278
+ return "ok"
279
+
280
+
281
  @app.get("/healthcheck")
282
  async def read_root():
283
  return {"status": "ok"}
workflows/utils/feedback.py CHANGED
@@ -9,6 +9,9 @@ class Feedback(BaseModel):
9
 
10
 
11
  def post_feedback(run_id: UUID4, feedback: Feedback):
 
 
 
12
  client = Client()
13
  client.create_feedback(
14
  str(run_id),
 
9
 
10
 
11
  def post_feedback(run_id: UUID4, feedback: Feedback):
12
+ print("Metric Type: ", feedback.metric_type)
13
+ print("Feedback On: ", feedback.feedback_on)
14
+
15
  client = Client()
16
  client.create_feedback(
17
  str(run_id),