light_chat 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +31 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +61 -0
- data/LICENSE.txt +21 -0
- data/README.md +137 -0
- data/Rakefile +12 -0
- data/lib/light_chat/client/helpers.rb +25 -0
- data/lib/light_chat/client.rb +151 -0
- data/lib/light_chat/version.rb +5 -0
- data/lib/light_chat.rb +7 -0
- data/light_chat.gemspec +37 -0
- data/sig/light_chat.rbs +4 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d02c066898158edc2c2a7b658e512344381737862900c22160e7dd6132011281
|
4
|
+
data.tar.gz: 233d7ad161041be3d4c6fa2509a7fea3432be8ee0e7b4f94c9a8d7c09ee2c8ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53b915ea050177b0c6adc742566c5e4dec52bee20b0507ecf03e22870634e2c59c75b9dc9fa579568b37c9a8c9c364f7b3301456cfdc17726aef86237abab2bc
|
7
|
+
data.tar.gz: 9ba169628bda7c2dbf8c5151a12432c602689d68219a5c5e8217930490b36bd982e89fae5335fe3f6e46227230785d36d3ba887b5284f46ad73f05cceb70d12e
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: single_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: single_quotes
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 40
|
17
|
+
|
18
|
+
Metrics/ClassLength:
|
19
|
+
Max: 200
|
20
|
+
|
21
|
+
Metrics/ParameterLists:
|
22
|
+
Max: 8
|
23
|
+
|
24
|
+
Metrics/AbcSize:
|
25
|
+
Max: 30
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 8
|
29
|
+
|
30
|
+
Layout/LineLength:
|
31
|
+
Max: 120
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
light_chat (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.1)
|
11
|
+
json (2.7.1)
|
12
|
+
language_server-protocol (3.17.0.3)
|
13
|
+
parallel (1.24.0)
|
14
|
+
parser (3.3.0.5)
|
15
|
+
ast (~> 2.4.1)
|
16
|
+
racc
|
17
|
+
racc (1.7.3)
|
18
|
+
rainbow (3.1.1)
|
19
|
+
rake (13.1.0)
|
20
|
+
regexp_parser (2.9.0)
|
21
|
+
rexml (3.2.6)
|
22
|
+
rspec (3.13.0)
|
23
|
+
rspec-core (~> 3.13.0)
|
24
|
+
rspec-expectations (~> 3.13.0)
|
25
|
+
rspec-mocks (~> 3.13.0)
|
26
|
+
rspec-core (3.13.0)
|
27
|
+
rspec-support (~> 3.13.0)
|
28
|
+
rspec-expectations (3.13.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.13.0)
|
31
|
+
rspec-mocks (3.13.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.13.0)
|
34
|
+
rspec-support (3.13.1)
|
35
|
+
rubocop (1.60.2)
|
36
|
+
json (~> 2.3)
|
37
|
+
language_server-protocol (>= 3.17.0)
|
38
|
+
parallel (~> 1.10)
|
39
|
+
parser (>= 3.3.0.2)
|
40
|
+
rainbow (>= 2.2.2, < 4.0)
|
41
|
+
regexp_parser (>= 1.8, < 3.0)
|
42
|
+
rexml (>= 3.2.5, < 4.0)
|
43
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
44
|
+
ruby-progressbar (~> 1.7)
|
45
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
46
|
+
rubocop-ast (1.30.0)
|
47
|
+
parser (>= 3.2.1.0)
|
48
|
+
ruby-progressbar (1.13.0)
|
49
|
+
unicode-display_width (2.5.0)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
arm64-darwin-21
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
light_chat!
|
56
|
+
rake (~> 13.0)
|
57
|
+
rspec (~> 3.0)
|
58
|
+
rubocop (~> 1.21)
|
59
|
+
|
60
|
+
BUNDLED WITH
|
61
|
+
2.2.11
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Pawel Niemczyk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# LightChat
|
2
|
+
|
3
|
+
Just a simple proxy for ChatGPT API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'light_chat'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
client = LightChat::Client.new(provider: :copilot, auth_token: '***')
|
17
|
+
# or
|
18
|
+
client = LightChat::Client.new(provider: :openai, auth_token: 'sk-***')
|
19
|
+
response = client.completions(messages: [{ role: 'user', content: 'What is the best way to sort an array in Ruby?' }])
|
20
|
+
response.dig('body', 'choices').select{|h| h.dig('message','role') == 'assistant'}.last.dig('message','content')
|
21
|
+
```
|
22
|
+
|
23
|
+
## Response
|
24
|
+
|
25
|
+
### OpenAI
|
26
|
+
|
27
|
+
```json
|
28
|
+
{
|
29
|
+
"body": {
|
30
|
+
"id": "chatcmpl-8vqyinqhdgaFzrqCpruHNq54Lw7QG",
|
31
|
+
"object": "chat.completion",
|
32
|
+
"created": 1708799036,
|
33
|
+
"model": "gpt-3.5-turbo-0125",
|
34
|
+
"choices": [
|
35
|
+
{
|
36
|
+
"index": 0,
|
37
|
+
"message": {
|
38
|
+
"role": "assistant",
|
39
|
+
"content": "```ruby\n# To sort an array in Ruby, you can use the `sort` method.\n# Here is an example:\n\nunsorted_array = [3, 1, 5, 2, 4]\nsorted_array = unsorted_array.sort\n\nputs sorted_array\n```"
|
40
|
+
},
|
41
|
+
"logprobs": nil,
|
42
|
+
"finish_reason": "stop"
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"usage": {"prompt_tokens": 276, "completion_tokens": 58, "total_tokens": 334},
|
46
|
+
"system_fingerprint": "fp_86156a94a0"},
|
47
|
+
"status": 200,
|
48
|
+
"headers": {
|
49
|
+
"date": "Sat, 24 Feb 2024 18:00:56 GMT",
|
50
|
+
"content-type": "application/json",
|
51
|
+
"transfer-encoding": "chunked",
|
52
|
+
"connection": "close",
|
53
|
+
"access-control-allow-origin": "*",
|
54
|
+
"cache-control": "no-cache, must-revalidate",
|
55
|
+
"openai-model": "gpt-3.5-turbo-0125",
|
56
|
+
"openai-organization": "user-zdk9028cnzqat2vago2gt5zls2",
|
57
|
+
"openai-processing-ms": "842",
|
58
|
+
"openai-version": "2020-10-01",
|
59
|
+
"strict-transport-security": "max-age=15724800; includeSubDomains",
|
60
|
+
"x-ratelimit-limit-requests": "10000",
|
61
|
+
"x-ratelimit-limit-tokens": "60000",
|
62
|
+
"x-ratelimit-remaining-requests": "9999",
|
63
|
+
"x-ratelimit-remaining-tokens": "55904",
|
64
|
+
"x-ratelimit-reset-requests": "8.64s",
|
65
|
+
"x-ratelimit-reset-tokens": "4.096s",
|
66
|
+
"x-request-id": "req_c848fdf20c3b2fd428af72eec1d6f47a",
|
67
|
+
"cf-cache-status": "DYNAMIC",
|
68
|
+
"set-cookie": "__cf_bm=hc.UHxVmsw2lyejO_ItRFJsTqxZkrGhjB5avdDtAT8s-1709799036-1.0-AXsxUZpRAAvj6tnzHP0KkCajTMS9zcCEy5e6VTAocR74h84sxoQppS8P/WOpAGN/SlKqwl67528hW9rcaQce4YBc=; path=/; expires=Sat, 24-Feb-24 18:00:56 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=IZPhM.UlilrcQmlcImnDAEqzW_FfHfpYpvwDu.TOEqg-1709299036977-0.0-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None",
|
69
|
+
"server": "cloudflare",
|
70
|
+
"cf-ray": "85a9be167ef96e99-PRG",
|
71
|
+
"alt-svc": "h3=\":443\"; ma=86400"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
### Copilot
|
77
|
+
|
78
|
+
```json
|
79
|
+
{
|
80
|
+
"body": {
|
81
|
+
"choices": [
|
82
|
+
{
|
83
|
+
"content_filter_results": {
|
84
|
+
"hate": { "filtered": false, "severity": "safe" },
|
85
|
+
"self_harm": { "filtered": false, "severity": "safe" },
|
86
|
+
"sexual": { "filtered": false, "severity": "safe" },
|
87
|
+
"violence": { "filtered": false, "severity": "safe" }
|
88
|
+
},
|
89
|
+
"finish_reason": "stop",
|
90
|
+
"index": 0,
|
91
|
+
"message": {
|
92
|
+
"content": "The best way to sort an array in Ruby is to use the `sort` method. The `sort` method sorts the elements of an array in ascending order by default. If you want to sort the array in descending order, you can use the `sort` method with a block and reverse the comparison result. Here's an example:\n\n```ruby\n# Sorting in ascending order\narray = [5, 2, 8, 1, 9]\nsorted_array = array.sort\nputs sorted_array # Output: [1, 2, 5, 8, 9]\n\n# Sorting in descending order\narray = [5, 2, 8, 1, 9]\nsorted_array = array.sort { |a, b| b <=> a }\nputs sorted_array # Output: [9, 8, 5, 2, 1]\n```\n\nIn the example above, the `sort` method is used to sort the `array` in ascending order. The resulting sorted array is then printed to the console. To sort the array in descending order, a block is passed to the `sort` method, which reverses the comparison result using the spaceship operator (`<=>`).",
|
93
|
+
"role": "assistant" }
|
94
|
+
}
|
95
|
+
],
|
96
|
+
"created": 1708798726,
|
97
|
+
"id": "chatcmpl-8vqtib9Uh24ynOJOacTucZ9KtYzZ",
|
98
|
+
"prompt_filter_results": [
|
99
|
+
{
|
100
|
+
"content_filter_results": {
|
101
|
+
"hate": { "filtered": false, "severity": "safe" },
|
102
|
+
"self_harm": { "filtered": false, "severity": "safe" },
|
103
|
+
"sexual": { "filtered": false, "severity": "safe" },
|
104
|
+
"violence": { "filtered": false, "severity": "safe" }
|
105
|
+
},
|
106
|
+
"prompt_index": 0
|
107
|
+
}
|
108
|
+
],
|
109
|
+
"usage": { "completion_tokens": 248, "prompt_tokens": 276, "total_tokens": 524 } },
|
110
|
+
"status": 200,
|
111
|
+
"headers": {
|
112
|
+
"content-security-policy": "default-src 'none'; sandbox",
|
113
|
+
"content-type": "application/json",
|
114
|
+
"strict-transport-security": "max-age=31536000",
|
115
|
+
"x-request-id": "cfecd8b6-eacf-ec55-d017-185695da0e1c",
|
116
|
+
"date": "Sat, 24 Feb 2024 18:00:47 GMT",
|
117
|
+
"content-length": "1616",
|
118
|
+
"x-github-backend": "Kubernetes",
|
119
|
+
"x-github-request-id": "EC04:62E6:1226D72:24ED480:65DA3306",
|
120
|
+
"connection": "close"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
```
|
124
|
+
|
125
|
+
## Development
|
126
|
+
|
127
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
128
|
+
|
129
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
130
|
+
|
131
|
+
## Contributing
|
132
|
+
|
133
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/light_chat.
|
134
|
+
|
135
|
+
## License
|
136
|
+
|
137
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module LightChat
|
6
|
+
class Client
|
7
|
+
class Helpers
|
8
|
+
def self.hex_str(length)
|
9
|
+
SecureRandom.hex(length / 2)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.new_machine_id
|
13
|
+
hex_str(64)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.new_session_id
|
17
|
+
"#{hex_str(8)}-#{hex_str(4)}-#{hex_str(4)}-#{hex_str(4)}-#{hex_str(25)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.request_id
|
21
|
+
"#{hex_str(8)}-#{hex_str(4)}-#{hex_str(4)}-#{hex_str(4)}-#{hex_str(12)}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require_relative 'client/helpers'
|
6
|
+
|
7
|
+
module LightChat
|
8
|
+
class Client
|
9
|
+
ROLES = %w[system user assistant].freeze
|
10
|
+
|
11
|
+
def initialize(provider:, options: {}, headers: {}, auth_token: nil, machine_id: nil, session_id: nil,
|
12
|
+
providers_definition: nil)
|
13
|
+
@provider = provider
|
14
|
+
@options = options
|
15
|
+
@headers = headers
|
16
|
+
@auth_token = auth_token
|
17
|
+
@machine_id = machine_id
|
18
|
+
@session_id = session_id
|
19
|
+
@providers = providers_definition || default_providers_definition
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :provider, :options, :headers, :auth_token, :machine_id, :session_id, :providers
|
23
|
+
|
24
|
+
def completions(messages:, opts: {}, with_system_setup: true, token: nil)
|
25
|
+
request(
|
26
|
+
http_method: :post,
|
27
|
+
url: "#{providers[provider][:base_url]}/#{providers[provider][:completions_path]}",
|
28
|
+
body: build_body(messages: messages, opts: opts, with_system_setup: with_system_setup),
|
29
|
+
headers: completions_headers(token: token)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def build_body(messages:, opts: {}, with_system_setup: true)
|
36
|
+
return completions_options.merge(opts).merge(messages: messages) unless with_system_setup
|
37
|
+
|
38
|
+
updated_messages = if messages.find do |message|
|
39
|
+
message['role'] == 'system'
|
40
|
+
end
|
41
|
+
messages
|
42
|
+
else
|
43
|
+
[system_setup_message] + messages
|
44
|
+
end
|
45
|
+
|
46
|
+
completions_options.merge(opts).merge(messages: updated_messages)
|
47
|
+
end
|
48
|
+
|
49
|
+
def system_setup_message
|
50
|
+
{
|
51
|
+
role: 'system',
|
52
|
+
content: providers[provider][:system_setup]
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def request(http_method:, url:, body: nil, headers: {})
|
57
|
+
uri = URI(url)
|
58
|
+
|
59
|
+
http = ::Net::HTTP.new(uri.host, uri.port)
|
60
|
+
http.use_ssl = uri.scheme == 'https'
|
61
|
+
|
62
|
+
request_class = case http_method.to_sym
|
63
|
+
when :get
|
64
|
+
Net::HTTP::Get
|
65
|
+
when :post
|
66
|
+
Net::HTTP::Post
|
67
|
+
when :put
|
68
|
+
Net::HTTP::Put
|
69
|
+
when :delete
|
70
|
+
Net::HTTP::Delete
|
71
|
+
else
|
72
|
+
raise ArgumentError, "Unsupported HTTP method: #{http_method}"
|
73
|
+
end
|
74
|
+
|
75
|
+
request = request_class.new(uri)
|
76
|
+
request['Content-Type'] = 'application/json'
|
77
|
+
headers.each { |key, value| request[key] = value }
|
78
|
+
request.body = JSON.generate(body) if body
|
79
|
+
|
80
|
+
response = http.request(request)
|
81
|
+
|
82
|
+
body = if response.content_type == 'application/json'
|
83
|
+
JSON.parse(response.body)
|
84
|
+
else
|
85
|
+
response.body
|
86
|
+
end
|
87
|
+
{
|
88
|
+
'body' => body,
|
89
|
+
'status' => response.code.to_i,
|
90
|
+
'headers' => response.each_header.to_a.to_h
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def completions_options
|
95
|
+
providers[provider][:completions_default_options].merge(options)
|
96
|
+
end
|
97
|
+
|
98
|
+
def completions_headers(token: nil)
|
99
|
+
providers[provider][:default_headers].merge(headers).merge('Authorization' => "Bearer #{token || auth_token}",
|
100
|
+
'X-Request-Id' => Helpers.request_id)
|
101
|
+
end
|
102
|
+
|
103
|
+
def default_providers_definition # rubocop:disable Metrics/MethodLength
|
104
|
+
{
|
105
|
+
openai: {
|
106
|
+
base_url: 'https://api.openai.com',
|
107
|
+
completions_path: 'v1/chat/completions',
|
108
|
+
completions_default_options: {
|
109
|
+
model: 'gpt-3.5-turbo',
|
110
|
+
max_tokens: 4096,
|
111
|
+
temperature: 0.1
|
112
|
+
},
|
113
|
+
models: %w[gpt-3.5-turbo gpt-3.5-turbo-16k gpt-3.5-turbo-instruct gpt-3.5-turbo-0125 gpt-3.5-turbo-0301
|
114
|
+
gpt-3.5-turbo-0613],
|
115
|
+
default_headers: {
|
116
|
+
'Content-Type' => 'application/json',
|
117
|
+
'X-Request-Id' => Helpers.request_id
|
118
|
+
},
|
119
|
+
system_setup: "\nYou are an AI programming assistant.\nFollow the user's requirements carefully & to the letter.\nYour expertise is strictly limited to software development topics.\nKeep your answers short and impersonal.\n\nYou can answer general programming questions and perform the following tasks:\n* Ask a question about the files in your current workspace\n* Explain how the selected code works\n* Generate unit tests for the selected code\n* Propose a fix for the problems in the selected code\n* Scaffold code for a new workspace\n* Create a new Jupyter Notebook\n* Find relevant code to your query\n* Ask questions about VS Code\n* Generate query parameters for workspace search\n* Ask about VS Code extension development\n* Ask how to do something in the terminal\nYou use the GPT-3.5-TURBO version of OpenAI's GPT models.\nFirst think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.\nThen output the code in a single code block.\nMinimize any other prose.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nYou can only give one reply for each conversation turn." # rubocop:disable Layout/LineLength
|
120
|
+
},
|
121
|
+
copilot: {
|
122
|
+
base_url: 'https://api.githubcopilot.com',
|
123
|
+
completions_path: 'chat/completions',
|
124
|
+
completions_default_options: {
|
125
|
+
model: 'gpt-3.5-turbo',
|
126
|
+
max_tokens: 4096,
|
127
|
+
temperature: 0.1,
|
128
|
+
top_p: 1,
|
129
|
+
n: 1,
|
130
|
+
stream: false
|
131
|
+
},
|
132
|
+
models: ['gpt-3.5-turbo'],
|
133
|
+
default_headers: {
|
134
|
+
'Content-Type' => 'application/json',
|
135
|
+
'X-GitHub-Api-Version' => '2023-07-07',
|
136
|
+
'VScode-MachineId' => machine_id || Helpers.new_machine_id,
|
137
|
+
'Editor-Version' => 'vscode/1.86.2',
|
138
|
+
'Editor-Plugin-Version' => 'copilot-chat/0.12.2',
|
139
|
+
'Openai-Organization' => 'github-copilot',
|
140
|
+
'Copilot-Integration-Id' => 'vscode-chat',
|
141
|
+
'VScode-SessionId' => session_id || Helpers.new_session_id,
|
142
|
+
'Accept' => '*/*',
|
143
|
+
'Connection' => 'close',
|
144
|
+
'X-Request-Id' => Helpers.request_id
|
145
|
+
},
|
146
|
+
system_setup: "\nYou are an AI programming assistant.\nFollow the user's requirements carefully & to the letter.\nYour expertise is strictly limited to software development topics.\nKeep your answers short and impersonal.\n\nYou can answer general programming questions and perform the following tasks:\n* Ask a question about the files in your current workspace\n* Explain how the selected code works\n* Generate unit tests for the selected code\n* Propose a fix for the problems in the selected code\n* Scaffold code for a new workspace\n* Create a new Jupyter Notebook\n* Find relevant code to your query\n* Ask questions about VS Code\n* Generate query parameters for workspace search\n* Ask about VS Code extension development\n* Ask how to do something in the terminal\nYou use the GPT-3.5-TURBO version of OpenAI's GPT models.\nFirst think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.\nThen output the code in a single code block.\nMinimize any other prose.\nUse Markdown formatting in your answers.\nMake sure to include the programming language name at the start of the Markdown code blocks.\nAvoid wrapping the whole response in triple backticks.\nYou can only give one reply for each conversation turn." # rubocop:disable Layout/LineLength
|
147
|
+
}
|
148
|
+
}
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
data/lib/light_chat.rb
ADDED
data/light_chat.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/light_chat/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'light_chat'
|
7
|
+
spec.version = LightChat::VERSION
|
8
|
+
spec.authors = ['Pawel Niemczyk']
|
9
|
+
spec.email = ['pniemczyk.info@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Just a proxy for chat GPT API.'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/pniemczyk/light_chat"
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = [spec.homepage, 'blob', 'master', 'CHANGELOG.md'].join('/')
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = 'exe'
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, check out our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
end
|
data/sig/light_chat.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: light_chat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pawel Niemczyk
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Just a proxy for chat GPT API.
|
14
|
+
email:
|
15
|
+
- pniemczyk.info@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rspec"
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/light_chat.rb
|
28
|
+
- lib/light_chat/client.rb
|
29
|
+
- lib/light_chat/client/helpers.rb
|
30
|
+
- lib/light_chat/version.rb
|
31
|
+
- light_chat.gemspec
|
32
|
+
- sig/light_chat.rbs
|
33
|
+
homepage: https://github.com/pniemczyk/light_chat
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
metadata:
|
37
|
+
homepage_uri: https://github.com/pniemczyk/light_chat
|
38
|
+
source_code_uri: https://github.com/pniemczyk/light_chat
|
39
|
+
changelog_uri: https://github.com/pniemczyk/light_chat/blob/master/CHANGELOG.md
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.6.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubygems_version: 3.2.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Just a proxy for chat GPT API.
|
59
|
+
test_files: []
|