mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-16 08:21:55 +00:00
fix ts check
This commit is contained in:
parent
0c7ee142cb
commit
5465d5fca3
@ -51,6 +51,6 @@ We value your input and want to ensure you can easily share your thoughts and re
|
||||
|
||||
- **Bug Reports**: If you encounter any bugs or unexpected behavior, please submit an issue on our [GitHub Issues](https://github.com/infiolab/infio-copilot/issues) page. Be sure to include as much detail as possible to help us reproduce and address the problem.
|
||||
- **Feature Requests**: For new feature ideas or enhancements, please use our [GitHub Discussions - Ideas & Feature Requests](https://github.com/infiolab/infio-copilot/discussions/categories/ideas) page. Create a new discussion to share your suggestions.
|
||||
## License
|
||||
·## License
|
||||
|
||||
This project is licensed under the [MIT License](LICENSE).
|
||||
|
||||
4
example_notes/Block quote (a tale of two cities).md
Normal file
4
example_notes/Block quote (a tale of two cities).md
Normal file
@ -0,0 +1,4 @@
|
||||
# A Tale of Two Cities
|
||||
|
||||
The most famous quote from this book is:
|
||||
>
|
||||
21
example_notes/Code generation (Kadane algorithm python).md
Normal file
21
example_notes/Code generation (Kadane algorithm python).md
Normal file
@ -0,0 +1,21 @@
|
||||
## Kadane's algorithm
|
||||
|
||||
Kadane's algorithm is an $O(n)$ solution to this problem.
|
||||
The key idea is that for each element, we have only 2 choices:
|
||||
|
||||
- Add this element to the current subset.
|
||||
- Start a new subset.
|
||||
|
||||
Due to this reasons, the problem can a viewed as a sliding window problem.
|
||||
|
||||
The general steps are as follows:
|
||||
|
||||
1. Initialize two variables, say `currentSum` and `maxSum`. Set both of them to the first element of the array.
|
||||
2. Loop through from the 2nd to the last element in the array.
|
||||
1. Decide to include the current number or to start a new subset using: `currentSum = max(num, currentSum + num)`
|
||||
2. If the current value of the subset is the best so far update `maxSum`
|
||||
|
||||
|
||||
```python
|
||||
|
||||
```
|
||||
21
example_notes/Code generation (Kadane algorithm rust).md
Normal file
21
example_notes/Code generation (Kadane algorithm rust).md
Normal file
@ -0,0 +1,21 @@
|
||||
## Kadane's algorithm
|
||||
|
||||
Kadane's algorithm is an $O(n)$ solution to this problem.
|
||||
The key idea is that for each element, we have only 2 choices:
|
||||
|
||||
- Add this element to the current subset.
|
||||
- Start a new subset.
|
||||
|
||||
Due to this reasons, the problem can a viewed as a sliding window problem.
|
||||
|
||||
The general steps are as follows:
|
||||
|
||||
1. Initialize two variables, say `currentSum` and `maxSum`. Set both of them to the first element of the array.
|
||||
2. Loop through from the 2nd to the last element in the array.
|
||||
1. Decide to include the current number or to start a new subset using: `currentSum = max(num, currentSum + num)`
|
||||
2. If the current value of the subset is the best so far update `maxSum`
|
||||
|
||||
|
||||
```rust
|
||||
|
||||
```
|
||||
@ -0,0 +1,22 @@
|
||||
## Kadane's algorithm
|
||||
|
||||
Kadane's algorithm is an $O(n)$ solution to this problem.
|
||||
The key idea is that for each element, we have only 2 choices:
|
||||
|
||||
- Add this element to the current subset.
|
||||
- Start a new subset.
|
||||
|
||||
Due to this reasons, the problem can a viewed as a sliding window problem.
|
||||
|
||||
The general steps are as follows:
|
||||
|
||||
1. Initialize two variables, say `currentSum` and `maxSum`. Set both of them to the first element of the array.
|
||||
2. Loop through from the 2nd to the last element in the array.
|
||||
1. Decide to include the current number or to start a new subset using: `currentSum = max(num, currentSum + num)`
|
||||
2. If the current value of the subset is the best so far update `maxSum`
|
||||
|
||||
|
||||
```typescript
|
||||
|
||||
|
||||
```
|
||||
@ -0,0 +1,9 @@
|
||||
# Fizz buzz
|
||||
Fizz buzz is often used as an interview problem to test if an applicant has basic programming knowledge. For a give `n`, the program should print the number between `1` and `n`. If the i-th number is divisible by three, it is replaced by `fizz`. If the number is divisible by five, it should print `buzz`. If the number is divisible by both, it should print `fizz buzz`.
|
||||
|
||||
In Javascript, you can implement it as follows:
|
||||
```javascript
|
||||
function fizzBuzz(n) {
|
||||
|
||||
}
|
||||
```
|
||||
@ -0,0 +1,7 @@
|
||||
# SOLID design principles
|
||||
SOLID is a set of design principles from Robert C. Martin. It consists of the following sub-principles:
|
||||
|
||||
- S: single responsibility principle
|
||||
- O: open closed principle
|
||||
-
|
||||
- D: Dependency inversion
|
||||
@ -0,0 +1,7 @@
|
||||
# Dead ReLU problem
|
||||
A neuron is considered dead if it does not activate for any of the training instance in the training dataset. Because it never activates it will never have a gradient due to the chain rule so it also cannot change anymore. The dead ReLU problem can have due to a wide variety of reasons, such as:
|
||||
-
|
||||
|
||||
This can be computational wasteful, since we still need to do the matrix multiplication, while it will never have an impact on the activations or gradients. It also reduces the learning capacity of the network, since it has to learn the same function with fewer neurons.
|
||||
|
||||
The gradient $\frac{dy}{dx} = 0$ if $x < 0$. This is no problem if it happens for some instance but it is a problem if it happens for all instances.
|
||||
24
example_notes/Math block test (softmax math function).md
Normal file
24
example_notes/Math block test (softmax math function).md
Normal file
@ -0,0 +1,24 @@
|
||||
# Softmax
|
||||
The softmax function transforms a vector into a probability distribution such that the sum of the vector is equal to 1.
|
||||
|
||||
$$
|
||||
|
||||
$$
|
||||
|
||||
## Numerical stability improvements
|
||||
|
||||
### Rescaling exponent
|
||||
|
||||
Due to the exponent operation, it is very likely that you get $\infty$ values.
|
||||
You can prevent this by ensuring that the largest possible exponent is $0$.
|
||||
This is typically implement by finding the maximum value and then subtracting it:
|
||||
|
||||
```python
|
||||
def softmax(x, dim=-1):
|
||||
c = x.max()
|
||||
return torch.exp(x - c) / torch.exp(x - c).sum(dim=dim, keepdim=True)
|
||||
```
|
||||
|
||||
## Calculating the log of the softmax
|
||||
|
||||
Calculating the log of the softmax can be numerically unstable so it is better to use the log-softmax approach.
|
||||
@ -0,0 +1,5 @@
|
||||
# Create random pillow image
|
||||
You can get a random color by randomly selecting a red, green and blue value. We can use these color values to generate a random Pillow image as follows:
|
||||
```python
|
||||
|
||||
```
|
||||
8
example_notes/Python code completion test (fizz buzz).md
Normal file
8
example_notes/Python code completion test (fizz buzz).md
Normal file
@ -0,0 +1,8 @@
|
||||
# Fizz buzz
|
||||
Fizz buzz is often used as an interview problem to test if an applicant has basic programming knowledge. For a give `n`, the program should print the number between `1` and `n`. If the i-th number is divisible by three, it is replaced by `fizz`. If the number is divisible by five, it should print `buzz`. If the number is divisible by both, it should print `fizz buzz`.
|
||||
|
||||
In Python, you can implement it as follows:
|
||||
```python
|
||||
def fizz_buzz(n: int) -> None:
|
||||
|
||||
```
|
||||
22
example_notes/README.md
Normal file
22
example_notes/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Demo vault Readme
|
||||
This is a demo Obsidian vault for testing the plugin.
|
||||
The command `npm run dev` will ensure the plugin artifacts are symlinked to correct locations allowing you to test the plugin in this vault.
|
||||
The file contains some example notes with useful content for testing the plugin.
|
||||
|
||||
The following files are used to test certain completion scenarios:
|
||||
- `Block quote (a tale of two cities).md`: contains an example note with a block quote. The plugin should be able to complete the block quote.
|
||||
- `Code generation (Kadane algorithm python).md`: contains an example note about the Kadane algorithm. The Python code is incomplete. The plugin should be able to complete the code.
|
||||
- `Code generation (Kadane algorithm rust).md`: contains an example note about the Kadane algorithm. The Rust code is incomplete. The plugin should be able to complete the code.
|
||||
- `Code generation (Kadane algorithm typescript).md`: contains an example note about the Kadane algorithm. The Typescript code is incomplete. The plugin should be able to complete the code.
|
||||
- `Javascript code completion test (fizz buzz).md`: contains an example note about the fizz buzz problem. The Javascript code is incomplete. The plugin should be able to complete the code.
|
||||
- `List completion in the middle (missing solid principles).md`: contains an example note about the SOLID design principles. The list of principles is incomplete. The plugin should be able to complete the list.
|
||||
- `List completion test (dead relu reasons).md`: contains an example note about the dead ReLU problem. The possible reasons for the dead ReLU problem are missing. The plugin should be able to complete the list of reasons.
|
||||
- `Math block test (softmax math function).md`: contains an example note about the softmax function. The latex code is for the softmax function is missing. The plugin should be able to complete the latex code based on the notes description and Python code.
|
||||
- `Python code completion test ( random pillow image).md`: contains an example note about the random pillow image. The Python code is incomplete. The plugin should be able to complete the code.
|
||||
- `Python code completion test (fizz buzz).md`: contains an example note about the fizz buzz problem. The Python code is incomplete. The plugin should be able to complete the code.
|
||||
- `task completion test (sub tasks todo list new york).md`: contains an example note about packing a todo list for a trip to New York. The todo list is incomplete. The plugin should be able to complete the todo list.
|
||||
- `task completion test (tasks todo list new york).md`: contains an example note about packing a todo list for a trip to New York. The todo list is incomplete. The plugin should be able to complete the todo list.
|
||||
- `Text completion test (Discreet Fourier transform).md`: contains an example note about the Discreet Fourier transform. The latex code for the Discreet Fourier transform is incomplete. The plugin should be able to complete the latex code based on the notes description and Python code.
|
||||
- `Text completion test (git sha hash checksums).md`: contains an example note about git sha hash. The plugin should be able to complete the paragraph about git sha hash.
|
||||
- `Title test (adapter design pattern).md`: contains an example note about the adapter design pattern. The plugin should be able to complete the title.
|
||||
- `Title test (dutch bitcoin).md`: contains an example note about the Dutch bitcoin. The plugin should be able to complete the title in Dutch.
|
||||
@ -0,0 +1,33 @@
|
||||
# Discreet Fourier transform
|
||||
|
||||
|
||||
$$
|
||||
\begin{bmatrix}
|
||||
\hat{f_1} \\
|
||||
\hat{f_2} \\
|
||||
\hat{f_3} \\
|
||||
... \\
|
||||
\hat{f_n}
|
||||
\end{bmatrix}
|
||||
|
||||
=
|
||||
|
||||
\begin{bmatrix}
|
||||
1 & 1 & 1 & ... & 1\\
|
||||
1 & w_n & w_n^2 & ... & w_n^{n-1}\\
|
||||
1 & w^2_n & w_n^4 & ... & w_n^{2(n-1)}\\
|
||||
... & ... & ... & ... & ...\\
|
||||
1 & w_n^{n-1} & w_n^{2(n-1)} & ... & w_n^{(n-1)^2}
|
||||
\end{bmatrix}
|
||||
|
||||
\begin{bmatrix}
|
||||
f_1 \\
|
||||
f_2 \\
|
||||
f_3 \\
|
||||
... \\
|
||||
f_n
|
||||
\end{bmatrix}
|
||||
$$
|
||||
$$
|
||||
w_n = e^{-2j \pi / n}
|
||||
$$
|
||||
@ -0,0 +1,12 @@
|
||||
|
||||
# Git sha hash checksums
|
||||
Every snapshot in git is check summed before it is stored using an SHA-1. This produces a 40-char string with hexadecimal chars (0-9 & a-f).
|
||||
|
||||
|
||||
This hash is based on the following information:
|
||||
|
||||
- The source tree of the commit (content of all the files in the repo and their locations).
|
||||
- The parent commit sha1
|
||||
- The author info
|
||||
- The committer info (right, those are different!)
|
||||
- The commit message
|
||||
3
example_notes/Title test (Chinese bitcoin).md
Normal file
3
example_notes/Title test (Chinese bitcoin).md
Normal file
@ -0,0 +1,3 @@
|
||||
#
|
||||
|
||||
比特币是一种新型的数字货币。 它与其他类型的数字货币不同,因为它的运作没有中央机构,也没有银行等中介机构。 相反,它是一个开放且去中心化的网络,由用户控制。 该网络遍布全球,任何人都可以参与。 由于底层技术的原因,比特币的工作原理与大多数人习惯的不同。 要完全理解它,您需要学习一段时间。 但有多少人了解互联网背后的技术是如何运作的? 最重要的是你可以使用它:你不必成为专家就可以安全地存储或发送比特币。 对于那些想了解更多信息的人,我们在下面编写了技术说明。 虽然不足以称自己为比特币专家,但也许足以在酒吧里留下深刻的印象. 你不必成为专家就可以安全地存储或发送比特币。
|
||||
52
example_notes/Title test (adapter design pattern).md
Normal file
52
example_notes/Title test (adapter design pattern).md
Normal file
@ -0,0 +1,52 @@
|
||||
#
|
||||
The adapter pattern allows the interface of an existing class/function to be *adapted* into another interface. This approach makes it possible to make existing classes/function work with others without modify their of their source code. It works as follows:
|
||||
|
||||
1. The adapter wraps an existing class A.
|
||||
2. The existing source code can now safely use the object of class A because it implement the expected interface.
|
||||
3. Upon receiving a call, the adapter translate the call into the expected format for class A.
|
||||
4. Class A does it computation and returns it results.
|
||||
5. The adapter translates the returned value back into the expected format by the interface.
|
||||
|
||||
It sounds much more complicate than you think. All it does is create a wrapper that changes the interface to a more convenient signature using some translation steps.
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
|
||||
class client
|
||||
|
||||
class ClientInterface
|
||||
<<interface>> ClientInterface
|
||||
|
||||
class Adapter
|
||||
Adapter : - service
|
||||
Adapter : + method(data)
|
||||
|
||||
class Service
|
||||
Service : ...
|
||||
Service : + noCompatableMethod(specialData)
|
||||
|
||||
client --> ClientInterface: expects
|
||||
Adapter ..> ClientInterface : implements
|
||||
Adapter --> Service : wraps
|
||||
```
|
||||
|
||||
## Application
|
||||
|
||||
- When you need to change an existing class signature but you can not or do not want to change the existing code.
|
||||
- When you want to use a 3rd-party class that doesn't implement your expected interface. E.g. when you want to use beautiful soup read XML.
|
||||
|
||||
## Advantages
|
||||
|
||||
- single responsibility principle: The adapter is only responsible the translation part. The actual functionality is delegated to the class it wraps.
|
||||
- open closed principle: You can introduce as many adapter as you want without breaking or changing any of the existing code.
|
||||
|
||||
## Disadvantage
|
||||
|
||||
- It adds an additional layer of abstraction, which increase the complexity of your code. Sometimes it is just simpler to change the signature of the existing code.
|
||||
|
||||
## Relationships to other patterns
|
||||
|
||||
- The adapter pattern changes the interface, while the decorator pattern and the proxy pattern do not.
|
||||
- Recursive composition is not possible with the adapter pattern, while it is possible with the decorator pattern.
|
||||
- The adapter pattern implements an existing interface, while the facade pattern implements a new (simpler interface).
|
||||
- The adapter pattern acts as a translator, while the bridge pattern combines existing code to create something new.
|
||||
6
example_notes/Title test (dutch bitcoin).md
Normal file
6
example_notes/Title test (dutch bitcoin).md
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
Bitcoin is een nieuw soort digitaal geld. Het verschilt van andere soorten digitaal geld, omdat het werkt zonder centrale autoriteit en zonder tussenpartijen zoals banken. In plaats daarvan is het een open en decentraal netwerk, waarbij gebruikers zelf alle touwtjes in handen hebben. Het netwerk is verspreid over de hele wereld en iedereen kan meedoen.
|
||||
|
||||
Bitcoin werkt vanwege onderliggende technologie anders dan de meeste mensen gewend zijn. Om het helemaal te begrijpen zal je het een tijd moeten bestuderen. Maar, hoeveel mensen begrijpen hoe de techniek achter het internet werkt? Het belangrijkste is dat je het kunt gebruiken: je hoeft geen expert te zijn om bitcoins veilig te bewaren of te versturen.
|
||||
|
||||
Voor wie toch net iets meer wil weten hebben wij onderstaande technische uitleg geschreven. Niet genoeg om jezelf bitcoinexpert te noemen, maar misschien wel om indruk mee te maken in de kroeg.
|
||||
6
example_notes/Title test (english bitcoin).md
Normal file
6
example_notes/Title test (english bitcoin).md
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
Bitcoin is a new kind of digital money. It differs from other types of digital money because it works without a central authority and without intermediaries such as banks. Instead, it is an open and decentralized network, where users are in control. The network is spread all over the world and anyone can participate.
|
||||
|
||||
Bitcoin works differently than most people are used to due to the underlying technology. To fully understand it you will have to study it for a while. But how many people understand how the technology behind the internet works? The most important thing is that you can use it: you don't have to be an expert to store or send bitcoins safely.
|
||||
|
||||
For those who want to know a little more, we have written the technical explanation below. Not enough to call yourself a bitcoin expert, but perhaps enough to make an impression in the pub.
|
||||
@ -0,0 +1,8 @@
|
||||
# Packing ToDo list for my trip to New York
|
||||
For this trip I still need to do the following:
|
||||
- [ ] Pack clothes and shoes
|
||||
- [ ] Check weather forecast
|
||||
- [ ] Prepare travel documents
|
||||
- [ ] Arrange pet care for my cat Fluffy
|
||||
- [ ] Pack pet supplies
|
||||
- [ ]
|
||||
@ -0,0 +1,6 @@
|
||||
# Packing ToDo list for my trip to New York
|
||||
For this trip I still need to do the following:
|
||||
- [ ] Pack clothes and shoes
|
||||
- [ ] Check weather forecast
|
||||
- [ ]
|
||||
- [ ] Prepare travel documents
|
||||
11555
package-lock.json
generated
Normal file
11555
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -8,8 +8,6 @@
|
||||
"dev": "npm run bundle-pglite && node esbuild.config.mjs",
|
||||
"build": "npm run bundle-pglite && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||
"version": "node version-bump.mjs",
|
||||
"lint:check": "(prettier --check --cache --cache-strategy content --cache-location node_modules/.cache/.prettiercache .) && (eslint .)",
|
||||
"lint:fix": "(prettier --write --cache --cache-strategy content --cache-location node_modules/.cache/.prettiercache .) && (eslint --fix .)",
|
||||
"type:check": "tsc --noEmit",
|
||||
"test": "jest"
|
||||
},
|
||||
@ -19,6 +17,7 @@
|
||||
"devDependencies": {
|
||||
"@types/diff": "^5.2.3",
|
||||
"@types/jest": "^29.5.13",
|
||||
"@types/lodash": "^4.14.195",
|
||||
"@types/lodash.debounce": "^4.0.9",
|
||||
"@types/lodash.isequal": "^4.5.8",
|
||||
"@types/node": "^16.11.6",
|
||||
@ -32,18 +31,19 @@
|
||||
"builtin-modules": "3.3.0",
|
||||
"drizzle-kit": "^0.26.2",
|
||||
"esbuild": "0.17.3",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.30.0",
|
||||
"eslint-plugin-neverthrow": "^1.1.4",
|
||||
"eslint-plugin-react": "^7.37.1",
|
||||
"eslint-plugin-react-hooks": "^5.0.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"obsidian": "latest",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier": "^3.4.2",
|
||||
"ts-jest": "^29.2.5",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "^5.6.2"
|
||||
"typescript": "^4.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.27.3",
|
||||
@ -72,6 +72,7 @@
|
||||
"lodash.isequal": "^4.5.0",
|
||||
"lru-cache": "^10.1.0",
|
||||
"lucide-react": "^0.447.0",
|
||||
"micromatch": "^4.0.5",
|
||||
"minimatch": "^10.0.1",
|
||||
"neverthrow": "^6.1.0",
|
||||
"openai": "^4.73.0",
|
||||
@ -83,6 +84,6 @@
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"uuid": "^10.0.0",
|
||||
"zod": "^3.23.8"
|
||||
"zod": "^3.22.4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,32 @@
|
||||
/* eslint-disable */
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
async function bundlePgliteResources() {
|
||||
const pgliteVersion = '0.2.14';
|
||||
const pglitePath = path.resolve(__dirname, '../node_modules/@electric-sql/pglite');
|
||||
const pgliteVersion = '0.2.14'
|
||||
const pglitePath = path.resolve(
|
||||
__dirname,
|
||||
'../node_modules/@electric-sql/pglite',
|
||||
)
|
||||
|
||||
// Read the files
|
||||
const wasmBuffer = await fs.readFile(path.join(pglitePath, 'dist/postgres.wasm'));
|
||||
const dataBuffer = await fs.readFile(path.join(pglitePath, 'dist/postgres.data'));
|
||||
const vectorBuffer = await fs.readFile(path.join(pglitePath, 'dist/vector.tar.gz'));
|
||||
const wasmBuffer = await fs.readFile(
|
||||
path.join(pglitePath, 'dist/postgres.wasm'),
|
||||
)
|
||||
const dataBuffer = await fs.readFile(
|
||||
path.join(pglitePath, 'dist/postgres.data'),
|
||||
)
|
||||
const vectorBuffer = await fs.readFile(
|
||||
path.join(pglitePath, 'dist/vector.tar.gz'),
|
||||
)
|
||||
|
||||
// Convert to base64
|
||||
const wasmBase64 = wasmBuffer.toString('base64');
|
||||
const dataBase64 = dataBuffer.toString('base64');
|
||||
const vectorBase64 = vectorBuffer.toString('base64');
|
||||
const wasmBase64 = wasmBuffer.toString('base64')
|
||||
const dataBase64 = dataBuffer.toString('base64')
|
||||
const vectorBase64 = vectorBuffer.toString('base64')
|
||||
|
||||
// Create the output file
|
||||
const output = `
|
||||
@ -27,13 +36,13 @@ export const pgliteResources = {
|
||||
dataBase64: '${dataBase64}',
|
||||
vectorBase64: '${vectorBase64}',
|
||||
};
|
||||
`;
|
||||
`
|
||||
|
||||
// Write the bundled resources
|
||||
await fs.writeFile(
|
||||
path.resolve(__dirname, '../src/database/pglite-resources.ts'),
|
||||
output
|
||||
);
|
||||
output,
|
||||
)
|
||||
}
|
||||
|
||||
bundlePgliteResources().catch(console.error);
|
||||
bundlePgliteResources().catch(console.error)
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { MarkdownView, Plugin } from "obsidian";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { MarkdownView, Plugin } from 'obsidian';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { APPLY_VIEW_TYPE } from "../../constants";
|
||||
import LLMManager from "../../core/llm/manager";
|
||||
import { InfioSettings } from "../../types/settings";
|
||||
import { manualApplyChangesToFile } from "../../utils/apply";
|
||||
import { removeAITags } from "../../utils/content-filter";
|
||||
import { PromptGenerator } from "../../utils/prompt-generator";
|
||||
import { APPLY_VIEW_TYPE } from '../../constants';
|
||||
import LLMManager from '../../core/llm/manager';
|
||||
import { CustomLLMModel } from '../../types/llm/model';
|
||||
import { InfioSettings } from '../../types/settings';
|
||||
import { manualApplyChangesToFile } from '../../utils/apply';
|
||||
import { removeAITags } from '../../utils/content-filter';
|
||||
import { PromptGenerator } from '../../utils/prompt-generator';
|
||||
|
||||
interface InlineEditProps {
|
||||
source: string;
|
||||
@ -172,7 +173,7 @@ export const InlineEdit: React.FC<InlineEditProps> = ({
|
||||
|
||||
const chatModel = settings.activeModels.find(
|
||||
(model) => model.name === selectedModel
|
||||
);
|
||||
) as CustomLLMModel;
|
||||
if (!chatModel) {
|
||||
setIsSubmitting(false);
|
||||
throw new Error("Invalid chat model");
|
||||
|
||||
@ -50,7 +50,7 @@ export function LLMProvider({ children }: PropsWithChildren) {
|
||||
if (!model) {
|
||||
throw new Error('Invalid chat model ID')
|
||||
}
|
||||
return model
|
||||
return model as CustomLLMModel
|
||||
}, [settings])
|
||||
|
||||
const applyModel = useMemo((): CustomLLMModel => {
|
||||
@ -62,12 +62,12 @@ export function LLMProvider({ children }: PropsWithChildren) {
|
||||
}
|
||||
if (model.provider === 'ollama') {
|
||||
return {
|
||||
provider: 'ollama',
|
||||
baseURL: settings.ollamaApplyModel.baseUrl,
|
||||
model: settings.ollamaApplyModel.model,
|
||||
...model,
|
||||
baseUrl: settings.ollamaApplyModel.baseUrl,
|
||||
name: settings.ollamaApplyModel.model,
|
||||
} as CustomLLMModel
|
||||
}
|
||||
}
|
||||
return model
|
||||
return model as CustomLLMModel
|
||||
}, [settings])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -108,9 +108,9 @@ class AutoComplete implements AutocompleteService {
|
||||
groq: settings.groqApiKey,
|
||||
infio: settings.infioApiKey,
|
||||
})
|
||||
const model: CustomLLMModel = settings.activeModels.find(
|
||||
const model = settings.activeModels.find(
|
||||
(option) => option.name === settings.chatModelId,
|
||||
)
|
||||
) as CustomLLMModel;
|
||||
const llm = new LLMClient(llm_manager, model);
|
||||
|
||||
return new AutoComplete(
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
import { Settings } from "../../../settings/versions";
|
||||
import { extractNextWordAndRemaining } from "../utils";
|
||||
import EventListener from "../../../event-listener";
|
||||
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
|
||||
import { InfioSettings } from "../../../types/settings";
|
||||
import { extractNextWordAndRemaining } from "../utils";
|
||||
|
||||
import State from "./state";
|
||||
|
||||
@ -166,7 +166,7 @@ class SuggestingState extends State {
|
||||
return `Suggesting for ${this.context.context}`;
|
||||
}
|
||||
|
||||
handleSettingChanged(settings: Settings): void {
|
||||
handleSettingChanged(settings: InfioSettings ): void {
|
||||
if (!settings.cacheSuggestions) {
|
||||
this.clearPrediction();
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ export class AnthropicProvider implements BaseLLMProvider {
|
||||
`Anthropic only supports string content for system messages`,
|
||||
)
|
||||
}
|
||||
return systemMessage
|
||||
return systemMessage as string
|
||||
}
|
||||
|
||||
private static isMessageEmpty(message: RequestMessage) {
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
GenerateContentResult,
|
||||
GenerateContentStreamResult,
|
||||
GoogleGenerativeAI,
|
||||
Part,
|
||||
} from '@google/generative-ai'
|
||||
|
||||
import { CustomLLMModel } from '../../types/llm/model'
|
||||
@ -207,7 +208,7 @@ export class GeminiProvider implements BaseLLMProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
}) as Part[],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* This provider is nearly identical to OpenAICompatibleProvider, but uses a custom OpenAI client
|
||||
* (NoStainlessOpenAI) to work around CORS issues specific to Ollama.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { PGlite } from '@electric-sql/pglite'
|
||||
import { type PGliteWithLive, live } from '@electric-sql/pglite/live'
|
||||
import { type PGliteWithLive, live } from '@electric-sql/pglite/dist/live'
|
||||
// import { PgliteDatabase, drizzle } from 'drizzle-orm/pglite'
|
||||
import { App, normalizePath } from 'obsidian'
|
||||
|
||||
|
||||
@ -112,6 +112,7 @@ export class VectorManager {
|
||||
path: file.path,
|
||||
mtime: file.stat.mtime,
|
||||
content: chunk.pageContent,
|
||||
embedding: [],
|
||||
metadata: {
|
||||
startLine: chunk.metadata.loc.lines.from as number,
|
||||
endLine: chunk.metadata.loc.lines.to as number,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { EditorView } from "@codemirror/view";
|
||||
import { LRUCache } from "lru-cache";
|
||||
import { App, TFile } from "obsidian";
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { EditorView } from '@codemirror/view'
|
||||
import { Editor, MarkdownView, Notice, Plugin, TFile } from 'obsidian'
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { Prec } from "@codemirror/state";
|
||||
import { keymap } from "@codemirror/view";
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { Prec } from "@codemirror/state";
|
||||
import {
|
||||
Decoration,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
EditorSelection,
|
||||
EditorState,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { Text } from "@codemirror/state";
|
||||
|
||||
export interface Suggestion {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { Transaction } from "@codemirror/state";
|
||||
|
||||
enum UserEvent {
|
||||
|
||||
@ -179,7 +179,7 @@ const ModelsSettings: React.FC<ModelsSettingsProps> = ({ settings, setSettings }
|
||||
<h2>Models</h2>
|
||||
<div className="infio-llm-chat-setting-title infio-chat-setting-item-container">
|
||||
<ModelList
|
||||
models={activeModels}
|
||||
models={activeModels as CustomLLMModel[]}
|
||||
chatModelKey={settings.chatModelId}
|
||||
applyModelKey={settings.applyModelId}
|
||||
onUpdateModel={handleUpdateModel}
|
||||
|
||||
@ -13,10 +13,10 @@ import { createRoot } from "react-dom/client";
|
||||
// } from '../constants'
|
||||
|
||||
import InfioPlugin from '../main';
|
||||
import { findFilesMatchingPatterns } from '../utils/glob-utils.ts';
|
||||
import { findFilesMatchingPatterns } from '../utils/glob-utils';
|
||||
import { getOllamaModels } from '../utils/ollama';
|
||||
|
||||
import AutoCompleteSettings from './AutoCompleteSettings.tsx';
|
||||
import AutoCompleteSettings from './AutoCompleteSettings';
|
||||
import CustomSettings from './CustomSettings';
|
||||
|
||||
export class InfioSettingTab extends PluginSettingTab {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { cloneDeep, each, get, has, isArray, isEqual, isNumber, isObject, isString, set, unset } from "lodash";
|
||||
import * as mm from "micromatch";
|
||||
import { err, ok, Result } from "neverthrow";
|
||||
|
||||
@ -7,12 +7,11 @@ import { SelectVector } from '../database/schema'
|
||||
import { ChatMessage, ChatUserMessage } from '../types/chat'
|
||||
import { ContentPart, RequestMessage } from '../types/llm/request'
|
||||
import {
|
||||
MentionableBlock,
|
||||
MentionableFile,
|
||||
MentionableBlock, MentionableCurrentFile, MentionableFile,
|
||||
MentionableFolder,
|
||||
MentionableImage,
|
||||
MentionableUrl,
|
||||
MentionableVault,
|
||||
MentionableVault
|
||||
} from '../types/mentionable'
|
||||
import { InfioSettings } from '../types/settings'
|
||||
|
||||
@ -99,7 +98,7 @@ export class PromptGenerator {
|
||||
const customInstructionMessage = this.getCustomInstructionMessage()
|
||||
|
||||
const currentFile = lastUserMessage.mentionables.find(
|
||||
(m) => m.type === 'current-file',
|
||||
(m): m is MentionableCurrentFile => m.type === 'current-file',
|
||||
)?.file
|
||||
const currentFileMessage = currentFile
|
||||
? await this.getCurrentFileMessage(currentFile)
|
||||
|
||||
@ -681,7 +681,9 @@ input[type='text'].infio-chat-list-dropdown-item-title-input {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.infio-chat-code-block.has-filename .infio-chat-code-block-header-button button {
|
||||
.infio-chat-code-block.has-filename
|
||||
.infio-chat-code-block-header-button
|
||||
button {
|
||||
box-shadow: none;
|
||||
border: 0;
|
||||
padding: 0 var(--size-4-2);
|
||||
@ -961,9 +963,6 @@ input[type='text'].infio-chat-list-dropdown-item-title-input {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* LLM Info
|
||||
*/
|
||||
@ -1383,7 +1382,7 @@ select.infio-ai-block-model-select::-ms-expand {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Apply
|
||||
*/
|
||||
|
||||
|
||||
@ -1,44 +1,75 @@
|
||||
{
|
||||
// TypeScript Configuration for Obsidian Plugin
|
||||
"compilerOptions": {
|
||||
/* Base Options */
|
||||
"baseUrl": ".", // Base path for module resolution
|
||||
"module": "ESNext", // Module code generation
|
||||
"target": "ES6", // ECMAScript target version
|
||||
/* Core Build Configuration
|
||||
* These options control the basic behavior of the TypeScript compiler
|
||||
*/
|
||||
"baseUrl": ".", // Root directory for resolving non-relative module names
|
||||
"module": "ESNext", // Use latest ECMAScript module syntax
|
||||
"target": "ES6", // Compile to ES6 (ES2015) JavaScript
|
||||
"moduleResolution": "node", // Use Node.js-style module resolution
|
||||
"moduleDetection": "force", // Force files to be treated as modules
|
||||
"noEmit": true, // Don't output JavaScript files (Obsidian handles compilation)
|
||||
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true, // Only perform type checking
|
||||
/* Source Map Configuration
|
||||
* Options for debugging and development
|
||||
*/
|
||||
"inlineSourceMap": true, // Generate source maps inline in output files
|
||||
"inlineSources": true, // Include source code in the source maps
|
||||
|
||||
/* Source Maps */
|
||||
"inlineSourceMap": true,
|
||||
"inlineSources": true,
|
||||
/* Type Checking Configuration
|
||||
* Controls the strictness of TypeScript's type system
|
||||
*/
|
||||
"strict": false, // Disable strict type checking for flexibility
|
||||
"noImplicitAny": false, // Allow variables to have implicit 'any' type
|
||||
"strictNullChecks": false, // Disable strict null checks for easier development
|
||||
|
||||
/* Type Checking */
|
||||
"strict": false,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
/* JavaScript and JSX Support
|
||||
* Configuration for JavaScript and React JSX
|
||||
*/
|
||||
"allowJs": true, // Allow JavaScript files to be compiled
|
||||
"jsx": "react-jsx", // Support React JSX syntax without importing React
|
||||
"resolveJsonModule": true, // Enable importing JSON files as modules
|
||||
|
||||
/* JavaScript Support */
|
||||
"allowJs": true,
|
||||
"jsx": "react-jsx",
|
||||
"resolveJsonModule": true,
|
||||
/* Module Import Configuration
|
||||
* Settings for module importing behavior
|
||||
*/
|
||||
"importHelpers": true, // Import helper functions for code generation
|
||||
"isolatedModules": true, // Ensure each file can be safely transpiled
|
||||
"allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export
|
||||
"esModuleInterop": true, // Enable interoperability between CommonJS and ES Modules;
|
||||
|
||||
/* Module Options */
|
||||
"importHelpers": true,
|
||||
"isolatedModules": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
/* Standard Library Configuration
|
||||
* Specify which APIs are available
|
||||
*/
|
||||
"lib": [
|
||||
"DOM", // Include DOM definitions
|
||||
"ES5", // Include ES5 APIs
|
||||
"ES6", // Include ES6/ES2015 APIs
|
||||
"ES7", // Include ES7/ES2016 APIs
|
||||
"ESNext" // Include latest ECMAScript features
|
||||
],
|
||||
|
||||
/* Libraries */
|
||||
"lib": ["DOM", "ES5", "ES6", "ES7"],
|
||||
/* Build Optimization
|
||||
* Options to improve build performance
|
||||
*/
|
||||
"skipLibCheck": true, // Skip type checking of declaration files
|
||||
|
||||
/* Optimization */
|
||||
"skipLibCheck": true,
|
||||
/* Development Configuration
|
||||
* Options to assist during development
|
||||
*/
|
||||
"noUnusedLocals": false, // Don't report errors on unused locals
|
||||
"noUnusedParameters": false, // Don't report errors on unused parameters
|
||||
"noFallthroughCasesInSwitch": false, // Don't report errors for fallthrough cases in switch
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
/* Module Resolution Paths
|
||||
* Custom path mappings for module resolution
|
||||
*/
|
||||
"paths": {
|
||||
"@codemirror/*": ["node_modules/@codemirror/*"], // Map CodeMirror imports
|
||||
"*": ["node_modules/*", "src/types/*"] // Fallback paths for module resolution
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "drizzle.config.ts", "__mocks__"]
|
||||
// Specify which files to include in compilation
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "__mocks__"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user