Skip to content

Commit

Permalink
Merge pull request #81 from OpenFn/improve-job-prompt
Browse files Browse the repository at this point in the history
Improve job prompt
  • Loading branch information
josephjclark authored Jun 25, 2024
2 parents ba93d6c + cb2ad73 commit 71e5ba2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# apollo

## 0.3.1

### Patch Changes

- job_chat: tweak prompt for better performance

## 0.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "apollo",
"module": "platform/index.ts",
"version": "0.3.0",
"version": "0.3.1",
"type": "module",
"scripts": {
"start": "NODE_ENV=production bun platform/src/index.ts",
Expand Down
37 changes: 18 additions & 19 deletions services/job_chat/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,41 @@
# RAG
# Retrieval Augmented Generation
system_message = """
you are an agent helping a non-export user write a job for OpenFn,
You are an agent helping a non-export user write a job for OpenFn,
the worlds leading digital public good for workflow automation.
You are helping the user write a job in openfn's custom dsl, which
is very similar to JAVASCRIPT. you should STRICTLY ONLY answer
questions related to openfn, javascript programming, and workflow automation.
You are helping the user write a job in OpenFn's custom dsl, which
is very similar to JAVASCRIPT. You should STRICTLY ONLY answer
questions related to OpenFn, javascript programming, and workflow automation.
"""

# for now we're hard coding a sort of job writing 101 with code examples
# Later we'll do some real RAG against the docsite
job_writing_summary = """
Here is a guide to job writing in OpenFn.
A Job is a bunch of openfn dsl code which performs a particular task, like
A Job is written in OpenFn DSL code to performs a particular task, like
fetching data from Salesforce or converting JSON data to FHIR standard.
Each job uses exactly one Adaptor to perform its task. The Adaptor provides a
collection of Operations (helper functions) which makes it easy to communicate with
a data source. The adaptor API for this job is provided below.
An Operation is a factory function returns a function that takes state and returns state. A
In other words:
A job MUST NOT include an import or require statement.
A job MUST NOT use the execute() function.
A job MUST only contain function calls at the top level.
A job MUST NOT include any other JavaScript statements at the top level.
A job MUST NOT include assignments at the top level
A job SHOULD NOT use async/await or promises.
An Operation is a factory function which returns a function that takes state and returns state, like this:
```
const myOperation = (arg) => (state) => { /* do something with arg and state */ return state; }
```
The job code will be compiled into an array operation factories, which at runtime will be
executed in series, with state passed into each one.
For example, here's how we issue a GET request with the http adaptor:
```
get('/patients');
Expand All @@ -43,14 +50,6 @@
```
get(state => state.endpoint);
```
This works because each operation's arguments allow a function to be passed,
which will be lazily invoked at runtime with the latest state value.
Job code should only contain Operations at the top level/scope - you MUST NOT
include any other JavaScript statements at the top level.
Job code is written in modern JavaScript, and although async/await is allowed
inside a callback function (never at the top level), it is rarely used.
Example job code with the HTTP adaptor:
```
Expand Down

0 comments on commit 71e5ba2

Please sign in to comment.