Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
evoprompt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grießhaber Daniel
evoprompt
Commits
aa579769
Commit
aa579769
authored
10 months ago
by
Max Kimmich
Browse files
Options
Downloads
Patches
Plain Diff
Add HTTP API endpoints
parent
cbd240bc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/main.py
+44
-0
44 additions, 0 deletions
api/main.py
optimization.py
+1
-2
1 addition, 2 deletions
optimization.py
with
45 additions
and
2 deletions
api/main.py
0 → 100644
+
44
−
0
View file @
aa579769
from
fastapi
import
FastAPI
,
Request
# from api.optimization import Backend
DEBUG
=
True
app
=
FastAPI
(
debug
=
DEBUG
,
title
=
"
Prompt Optimization Backend
"
)
# api = Backend(debug=DEBUG)
def
test
():
pass
# @app.get("/test")
# async def test_long_operation(request: Request):
# loop = asyncio.get_event_loop()
# result = await loop.run_in_executor(pool, test)
# return "ok"
# start optimization
@app.get
(
"
/run/{num_iterations}
"
)
async
def
run
(
num_iterations
:
int
)
->
str
:
# api.run_optimization(num_iterations)
return
"
ok
"
# TODO turn actions into router and allow to set actions dynamically
# perform optimizer-specific action
@app.get
(
"
/action/evolve/
"
)
async
def
evolve
(
prompt1
:
str
,
prompt2
:
str
)
->
str
:
return
f
"
This is the evolved prompt taking prompts
{
prompt1
}
and
{
prompt2
}
into account.
"
# get current genealogy of prompts
@app.get
(
"
/family_tree/get
"
)
async
def
get_family
()
->
dict
:
return
dict
()
@app.get
(
"
/
"
)
def
main
(
request
:
Request
)
->
str
:
return
"
server running
"
This diff is collapsed.
Click to expand it.
optimization.py
+
1
−
2
View file @
aa579769
...
@@ -49,10 +49,9 @@ class PromptOptimization:
...
@@ -49,10 +49,9 @@ class PromptOptimization:
self
.
_init
()
self
.
_init
()
def
_init
(
self
):
def
_init
(
self
):
#
use caching for evaluation
#
family_tree contains the relation of prompts to its parents
self
.
family_tree
:
dict
[
str
,
tuple
[
str
,
...]
|
None
]
=
{}
self
.
family_tree
:
dict
[
str
,
tuple
[
str
,
...]
|
None
]
=
{}
# all_prompts contains a list of Prompt objects that took part in the optimization
# all_prompts contains a list of Prompt objects that took part in the optimization
# converting prompts to Prompt object
self
.
all_prompts
:
dict
[
str
,
Prompt
]
=
{}
self
.
all_prompts
:
dict
[
str
,
Prompt
]
=
{}
def
reset
(
self
):
def
reset
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment