qb101 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/data/qb101.txt +52 -0
- data/lib/qb101.rb +171 -0
- data.tar.gz.sig +0 -0
- metadata +93 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d5e8fd3277a726283e04cc958f8d5e4cd80f69c80a3b04d884236ecdc709d8d
|
4
|
+
data.tar.gz: d88cd27c2554b8721597b18b7bc8d4aeb29c2d0aac8edd1b2bcd7b395e9898c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4dec04806442a4e9fa95fc2d994b87b40da1dd123b79095d565e85e5b1dd2a43f336f4bf38ab69f5143538d5c4dfd60bfbe4ea28e0bb7a1a4c2e856e038cfa0
|
7
|
+
data.tar.gz: 6ef29045aee502fbaeffe6bd829ecd6e17fb7a37ba8144dddaa89dba5462a417e21a1402a8cffbf097aa2a50329e914f855601faece76ec856877f99f9cd0fdb
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/data/qb101.txt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
<?ph schema="book[title,tags]/section[x]"?>
|
2
|
+
|
3
|
+
title: A Sample Questions File
|
4
|
+
tags: education learning book questions answers chatgpt
|
5
|
+
|
6
|
+
# Questions
|
7
|
+
|
8
|
+
Why ask questions?
|
9
|
+
|
10
|
+
## Generating a ChatGPT TOC
|
11
|
+
|
12
|
+
Write a table of contents for learning ChatGPT
|
13
|
+
|
14
|
+
## Introduction
|
15
|
+
|
16
|
+
Give me an overview of ChatGPT
|
17
|
+
What are the benefits of using ChatGPT?
|
18
|
+
|
19
|
+
## Getting Started with ChatGPT
|
20
|
+
|
21
|
+
What are the essentials of ChatGPT?
|
22
|
+
How do I set up an account and get started with ChatGPT?
|
23
|
+
|
24
|
+
## Basic Functions of ChatGPT
|
25
|
+
|
26
|
+
How can I properly engage with ChatGPT?
|
27
|
+
Give me an understanding of the importance of good communication with ChatGPT AI
|
28
|
+
|
29
|
+
## Advanced Functions of ChatGPT
|
30
|
+
|
31
|
+
How can I create a custom model?
|
32
|
+
How can I train a new model with ChatGPT?
|
33
|
+
|
34
|
+
## Applications of ChatGPT
|
35
|
+
|
36
|
+
What are the use cases for ChatGPT?
|
37
|
+
How can I incorporate ChatGPT into my organization?
|
38
|
+
|
39
|
+
## Tips for getting the best results with ChatGPT
|
40
|
+
|
41
|
+
How do I prepare my data for ChatGPT?
|
42
|
+
What tricks are there for better model building and AI understanding?
|
43
|
+
|
44
|
+
## Best practices for maintaining ChatGPT
|
45
|
+
|
46
|
+
How can I maintain and update my ChatGPT model
|
47
|
+
Give me tips for keeping my data safe and up-to-date
|
48
|
+
|
49
|
+
## Conclusion
|
50
|
+
|
51
|
+
Give me a recap of ChatGPT
|
52
|
+
What is the future of ChatGPT and AI?
|
data/lib/qb101.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: qb101.tb
|
4
|
+
|
5
|
+
# Description: Makes it convenient to create a questions and anwers book.
|
6
|
+
# To be used in conjunction with the ChatGpt2023 gem.
|
7
|
+
# see https://github.com/jrobertson/qb101/blob/main/data/qb101.txt for
|
8
|
+
# an example of questions used
|
9
|
+
|
10
|
+
require 'yatoc'
|
11
|
+
require 'polyrex-headings'
|
12
|
+
|
13
|
+
|
14
|
+
# This file contains 2 classes, the question book class and
|
15
|
+
# the answer book class.
|
16
|
+
|
17
|
+
|
18
|
+
class Qb101
|
19
|
+
|
20
|
+
def initialize(questions_file=nil)
|
21
|
+
|
22
|
+
questions_file ||= File.join(File.dirname(__FILE__), '..',
|
23
|
+
'data', 'qb101.txt')
|
24
|
+
|
25
|
+
s = File.read(questions_file)
|
26
|
+
@questions = s[/#.*/m]
|
27
|
+
@px = PolyrexHeadings.new(s, debug: false).to_polyrex
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def question(id)
|
32
|
+
|
33
|
+
found = @px.find_by_id(id.to_s)
|
34
|
+
found.x if found
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
alias q question
|
39
|
+
|
40
|
+
def questions()
|
41
|
+
doc = Rexle.new('<root>' + self.to_html + '</root>')
|
42
|
+
a = doc.root.xpath('//p/text()').map(&:to_s)
|
43
|
+
end
|
44
|
+
|
45
|
+
def tags()
|
46
|
+
@px.summary.tags
|
47
|
+
end
|
48
|
+
|
49
|
+
def title()
|
50
|
+
@px.summary.title
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_md()
|
54
|
+
@questions
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_html()
|
58
|
+
s = @questions.strip.gsub(/^([^\n#].[^\n]+)[\n]+/,'\1' + "\n\n")
|
59
|
+
Kramdown::Document.new(s).to_html
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_prompts()
|
63
|
+
|
64
|
+
# generates a Dynarex file for use with ChatAway class in ChaptGpt2023
|
65
|
+
dx = Dynarex.new('prompts/entry(prompt,type, redo)')
|
66
|
+
|
67
|
+
questions().each {|x| dx.create({prompt: x, type: 'completion'}) }
|
68
|
+
|
69
|
+
return dx
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_toc()
|
74
|
+
Yatoc.new(self.to_html(), min_sections: 1)
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_xml()
|
78
|
+
@px.to_xml(pretty: true)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
class Ab101
|
84
|
+
|
85
|
+
# note: the ab_xml file can be in CGRecorder log XML format
|
86
|
+
|
87
|
+
def initialize(qb_txt, ab_xml=nil, filepath: '.', debug: false)
|
88
|
+
|
89
|
+
@debug = debug
|
90
|
+
|
91
|
+
@qb = Qb101.new(qb_txt)
|
92
|
+
|
93
|
+
@dx = Dynarex.new('book[title, tags]/item(question, answer)')
|
94
|
+
@dx.title = @qb.title
|
95
|
+
@dx.tags = @qb.tags
|
96
|
+
|
97
|
+
@qb.questions.each {|q| @dx.create({question: q}) }
|
98
|
+
|
99
|
+
if ab_xml and File.exist?(ab_xml) then
|
100
|
+
|
101
|
+
dx = Dynarex.new(ab_xml)
|
102
|
+
|
103
|
+
# using each question, find the associated answer and
|
104
|
+
# add it the main record
|
105
|
+
|
106
|
+
@qb.questions.each do |q|
|
107
|
+
|
108
|
+
puts 'q: ' + q.inspect if @debug
|
109
|
+
|
110
|
+
# note: the find_by ... method is passing in a regex because passing
|
111
|
+
# in a String causes the xpath to execute which is known to have
|
112
|
+
# a serious bug when the value contains *and*.
|
113
|
+
if dx.schema =~ /question, answer/ then
|
114
|
+
|
115
|
+
found = dx.find_by_question /#{q}/
|
116
|
+
|
117
|
+
if found then
|
118
|
+
rx = @dx.find_by_question /#{q}/
|
119
|
+
rx.answer = found.answer
|
120
|
+
end
|
121
|
+
|
122
|
+
else
|
123
|
+
|
124
|
+
#puts 'dx: ' + dx.to_xml(pretty: true) if @debug
|
125
|
+
found = dx.find_by_prompt /#{q}/
|
126
|
+
puts 'found: ' + found.inspect if @debug
|
127
|
+
|
128
|
+
if found then
|
129
|
+
rx = @dx.find_by_question /#{q}/
|
130
|
+
rx.answer = found.result
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
#@dx.save ab_xml
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
def save(filename)
|
144
|
+
@dx.save filename
|
145
|
+
end
|
146
|
+
|
147
|
+
def to_html()
|
148
|
+
|
149
|
+
doc = Rexle.new('<body>' + @qb.to_html.gsub(/<p>[^>]+>/,'<div>\0</div>') \
|
150
|
+
+ '</body>')
|
151
|
+
answers = @dx.all.map(&:answer)
|
152
|
+
|
153
|
+
puts 'answers: ' + answers.inspect if @debug
|
154
|
+
|
155
|
+
doc.root.xpath('//p').each.with_index do |para, i|
|
156
|
+
|
157
|
+
e = Rexle::Element.new('p', attributes: {class: 'answer'})\
|
158
|
+
.add_text answers[i]
|
159
|
+
para.insert_after e
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
doc.root.xml pretty: true
|
164
|
+
end
|
165
|
+
|
166
|
+
def to_xml()
|
167
|
+
@dx.to_xml(pretty: true)
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qb101
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTIzMDMxNTE2MDkxOFoXDTI0MDMxNDE2MDkxOFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
18
|
+
ggGBAMRqRQyf6BMO94O6mrsHfqj7q0bhZAHRwEZxULSfwAlqVzJAgWH9mKIIA8+H
|
19
|
+
y4UcuZTvpFnsFzdOI+TofwG2r5G10PoKQQM2WrwUKZ/j51EAEJH4M93AJtjLBeJ5
|
20
|
+
Jx22Osus/xWsCcEeMiHuFvUiM/g53ywA2RjyoNEb153YBfoBqpMJAFbuSvJ1fsBd
|
21
|
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iKz2wEzhD00bVobcLZs0ya
|
36
|
+
cDl2AtC0eMMvV0NQ4Z3pXXWhcZTxxSRCN7e0OwtHxEH9mzN1kD4Dw9j4qQRaW0ac
|
37
|
+
LzC+vZ8VfAChCj7nNb47qf1JjcN/xgANU1A=
|
38
|
+
-----END CERTIFICATE-----
|
39
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yatoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.3'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.3.5
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.3'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.3.5
|
61
|
+
description:
|
62
|
+
email: digital.robertson@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- data/qb101.txt
|
68
|
+
- lib/qb101.rb
|
69
|
+
homepage: https://github.com/jrobertson/qb101
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubygems_version: 3.4.4
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Makes it convenient to create a questions and answers book. To be used in
|
92
|
+
conjunction with the ChatGpt2023 gem.
|
93
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|