@jpoly1219/context-extractor 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +35 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Extract relevant context from a codebase using a type-directed approach.
4
4
 
5
- ## npm Installation
5
+ ## Installation
6
+
7
+ ### npm
6
8
 
7
9
  Recommended.
8
10
 
@@ -10,7 +12,7 @@ Recommended.
10
12
  npm i @jpoly1219/context-extractor
11
13
  ```
12
14
 
13
- ## Manual Installation
15
+ ### Manual
14
16
 
15
17
  Not recommended. If the above steps do not work, please leave a GitHub issue.
16
18
 
@@ -84,24 +86,36 @@ node dist/runner.js
84
86
  1. Determine the type of the hole.
85
87
  2. Extract relevant types.
86
88
  3. Extract relevant headers.
89
+ 4. Optionally complete the hole with an LLM.
87
90
 
88
- This library exposes the API `extractWithNew`, which has the following definition:
91
+ This library exposes the method `extractContext`, which has the following definition:
89
92
 
90
93
  ```ts
91
- const extractWithNew = async (
94
+ const extractContext = async (
92
95
  language: Language,
93
96
  sketchPath: string,
94
- credentialsPath: string
95
- ) => {};
97
+ repoPath: string,
98
+ credentialsPath: string,
99
+ getCompletion: boolean
100
+ ): Promise<{ context: Context | null, completion: string | null }
96
101
 
97
102
  enum Language {
98
103
  TypeScript,
99
- OCaml,
104
+ OCaml
105
+ }
106
+
107
+ interface Context {
108
+ hole: string,
109
+ relevantTypes: Map<string, string[]>,
110
+ relevantHeaders: Map<string, string[]>
100
111
  }
101
112
  ```
102
113
 
103
- `sketchPath` is the full path to your `sketch.ts` or `sketch.ml` file.
104
- `credentialsPath` is the full path to your `credentials.json`.
114
+ - `sketchPath` is the full path to your sketch file with the typed hole construct (`_()` for TypeScript, `_` for OCaml).
115
+ - `repoPath` is the full path to your repository root.
116
+ - `credentialsPath` is the full path to your `credentials.json`.
117
+ - `getCompletion` is a flag to set if you want the LLM to complete the typed hole. This completion is saved in the `completion` field of the return result.
118
+ - `null` values will only be set if something goes wrong internally. When `getCompletion` is set to false, the `completion` field's value will be an empty string.
105
119
 
106
120
  ### credentials.json
107
121
 
@@ -123,8 +137,19 @@ The json has the following format:
123
137
  }
124
138
  ```
125
139
 
140
+ Internally, this is how fields above are populated when creating a new OpenAI client.
141
+
142
+ ```ts
143
+ const openai = new OpenAI({
144
+ apiKey,
145
+ baseURL: `${apiBase}/openai/deployments/${deployment}`,
146
+ defaultQuery: { "api-version": apiVersion },
147
+ defaultHeaders: { "api-key": apiKey }
148
+ })
149
+ ```
150
+
126
151
  ## Trying out the VSCode extension
127
152
 
128
153
  We have a Visual Studio Code extension that provides a frontend to this project.
129
154
 
130
- The extension is not publicly available, so you would need to request for a .vsix package.
155
+ The extension is not publicly available -- contact me at `jpoly@umich.edu` to request for a .vsix package.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpoly1219/context-extractor",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Extract relevant context from an incomplete program sketch.",
5
5
  "repository": {
6
6
  "type": "git",