Skip to content

Commit

Permalink
Remove the function interface
Browse files Browse the repository at this point in the history
The `function` interface is not a very useful layer of abstraction, and
we don't want to have to maintain it. This commit removes it from the
codebase.
  • Loading branch information
rlouf committed Nov 8, 2023
1 parent 3667e04 commit a64aa76
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 134 deletions.
20 changes: 8 additions & 12 deletions examples/babyagi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def perform_task_ppt(objective: str, task: str):
"""


perform_task = text.function(model, perform_task_ppt)


#####################
# Create a new task #
#####################
Expand Down Expand Up @@ -67,9 +64,6 @@ def create_tasks_fmt(result: str) -> List[str]:
return task_list


create_tasks = text.function(model, create_tasks_ppt, create_tasks_fmt)


########################
# Prioritize new tasks #
########################
Expand Down Expand Up @@ -104,9 +98,6 @@ def prioritize_tasks_fmt(result: str):
return task_list


prioritize_tasks = text.function(model, prioritize_tasks_ppt, prioritize_tasks_fmt)


objective = "Becoming rich while doing nothing."
first_task = {
"task_id": 1,
Expand Down Expand Up @@ -134,18 +125,23 @@ def one_cycle(objective: str, task_list, next_task_id: int):
"""

task = task_list.popleft()
result = perform_task(objective, task)
new_tasks = create_tasks(

prompt = perform_task_ppt(objective, task)
result = model(prompt)

prompt = create_tasks_ppt(
objective, first_task["task_name"], result, [first_task["task_name"]]
)
new_tasks = model(prompt)

for task in new_tasks:
next_task_id += 1
task_list.append({"task_id": next_task_id, "task_name": task})

prioritized_tasks = prioritize_tasks(
prompt = prioritize_tasks_ppt(
objective, [task["task_name"] for task in task_list], next_task_id
)
prioritized_tasks = model(prompt)

return task, result, prioritized_tasks, next_task_id

Expand Down
10 changes: 3 additions & 7 deletions examples/math_generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ def execute_code(code):
return result


answer_with_code = text.function(
models.text_completion.openai("text-davinci-003"),
answer_with_code_prompt,
execute_code,
)

result = answer_with_code(question, examples)
prompt = answer_with_code_prompt(question, examples)
answer = models.text_completion.openai("text-davinci-003")(prompt)
result = execute_code(answer)
print(f"It takes Carla {result:.0f} minutes to download the file.")
1 change: 0 additions & 1 deletion outlines/text/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .functions import function
from .generate import continuation
from .prompts import prompt, render
63 changes: 0 additions & 63 deletions outlines/text/functions.py

This file was deleted.

51 changes: 0 additions & 51 deletions tests/text/test_function.py

This file was deleted.

0 comments on commit a64aa76

Please sign in to comment.